LibrePCB Developers Documentation
Loading...
Searching...
No Matches
componentgatelistmodel.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_COMPONENTGATELISTMODEL_H
21#define LIBREPCB_EDITOR_COMPONENTGATELISTMODEL_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 ComponentGateEditor;
43class ComponentSignalNameListModel;
44class GraphicsLayerList;
45class GraphicsScene;
46class LibraryElementCache;
47class UndoCommand;
48class UndoCommandGroup;
49class UndoStack;
50
51/*******************************************************************************
52 * Class ComponentGateListModel
53 ******************************************************************************/
54
59 : public QObject,
60 public slint::Model<ui::ComponentGateData> {
61 Q_OBJECT
62
63public:
64 // Constructors / Destructor
67 explicit ComponentGateListModel(const Workspace& ws,
68 const GraphicsLayerList& layers,
69 const LibraryElementCache& cache,
70 QObject* parent = nullptr) noexcept;
71 ~ComponentGateListModel() noexcept;
72
73 // General Methods
75 QPointer<Component> component,
76 QPointer<GraphicsScene> componentScene,
77 const std::shared_ptr<ComponentSignalNameListModel>& sigs,
78 UndoStack* stack, const bool* wizardMode) noexcept;
79 slint::Image renderScene(int gate, float width, float height) noexcept;
80 void add();
81
82 // Implementations
83 std::size_t row_count() const override;
84 std::optional<ui::ComponentGateData> row_data(std::size_t i) const override;
85 void set_row_data(std::size_t i,
86 const ui::ComponentGateData& data) noexcept override;
87
88 // Operator Overloadings
89 ComponentGateListModel& operator=(const ComponentGateListModel& rhs) = delete;
90
91private:
92 void trigger(int index, std::shared_ptr<ComponentSymbolVariantItem> obj,
93 ui::ComponentGateAction a) noexcept;
94 void listEdited(const ComponentSymbolVariantItemList& list, int index,
95 const std::shared_ptr<const ComponentSymbolVariantItem>& item,
96 ComponentSymbolVariantItemList::Event event) noexcept;
97 void gateUiDataChanged() noexcept;
98 void execCmd(UndoCommand* cmd, bool updateSuffixes);
100
101private:
110 const bool* mWizardMode;
111
112 QList<std::shared_ptr<ComponentGateEditor>> mItems;
113
114 // Slots
116};
117
118/*******************************************************************************
119 * End of File
120 ******************************************************************************/
121
122} // namespace editor
123} // namespace librepcb
124
125#endif
The Component class represents a "generic" device in the library.
Definition component.h:73
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition componentsymbolvariantitem.h:54
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 ComponentGateEditor class.
Definition componentgateeditor.h:58
The ComponentGateListModel class.
Definition componentgatelistmodel.h:60
void gateUiDataChanged() noexcept
Definition componentgatelistmodel.cpp:291
void listEdited(const ComponentSymbolVariantItemList &list, int index, const std::shared_ptr< const ComponentSymbolVariantItem > &item, ComponentSymbolVariantItemList::Event event) noexcept
Definition componentgatelistmodel.cpp:255
ComponentSymbolVariantItemList * mList
Definition componentgatelistmodel.h:108
std::unique_ptr< UndoCommandGroup > createSuffixUpdateCmd()
Definition componentgatelistmodel.cpp:325
const GraphicsLayerList & mLayers
Definition componentgatelistmodel.h:103
slint::Image renderScene(int gate, float width, float height) noexcept
Definition componentgatelistmodel.cpp:115
void trigger(int index, std::shared_ptr< ComponentSymbolVariantItem > obj, ui::ComponentGateAction a) noexcept
Definition componentgatelistmodel.cpp:218
QPointer< Component > mComponent
Definition componentgatelistmodel.h:105
void add()
Definition componentgatelistmodel.cpp:133
const Workspace & mWorkspace
Definition componentgatelistmodel.h:102
void set_row_data(std::size_t i, const ui::ComponentGateData &data) noexcept override
Definition componentgatelistmodel.cpp:196
void setReferences(ComponentSymbolVariantItemList *list, QPointer< Component > component, QPointer< GraphicsScene > componentScene, const std::shared_ptr< ComponentSignalNameListModel > &sigs, UndoStack *stack, const bool *wizardMode) noexcept
Definition componentgatelistmodel.cpp:75
const LibraryElementCache & mCache
Definition componentgatelistmodel.h:104
ComponentSymbolVariantItemList::OnEditedSlot mOnEditedSlot
Definition componentgatelistmodel.h:115
std::size_t row_count() const override
Definition componentgatelistmodel.cpp:183
QPointer< GraphicsScene > mComponentScene
Definition componentgatelistmodel.h:106
std::optional< ui::ComponentGateData > row_data(std::size_t i) const override
Definition componentgatelistmodel.cpp:187
const bool * mWizardMode
Definition componentgatelistmodel.h:110
QPointer< UndoStack > mUndoStack
Definition componentgatelistmodel.h:109
QList< std::shared_ptr< ComponentGateEditor > > mItems
Definition componentgatelistmodel.h:112
std::shared_ptr< ComponentSignalNameListModel > mSignals
Definition componentgatelistmodel.h:107
void execCmd(UndoCommand *cmd, bool updateSuffixes)
Definition componentgatelistmodel.cpp:299
ComponentGateListModel(const ComponentGateListModel &other)=delete
The ComponentSignalNameListModel class.
Definition componentsignalnamelistmodel.h:50
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The GraphicsScene class.
Definition graphicsscene.h:64
Cache for fast access to library elements.
Definition libraryelementcache.h:56
The UndoCommandGroup class makes it possible to pack multiple undo commands together (it acts as a pa...
Definition undocommandgroup.h:44
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