LibrePCB Developers Documentation
Loading...
Searching...
No Matches
componentsignalnamelistmodel.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_COMPONENTSIGNALNAMELISTMODEL_H
21#define LIBREPCB_EDITOR_COMPONENTSIGNALNAMELISTMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36namespace editor {
37
38class UndoCommand;
39class UndoStack;
40
41/*******************************************************************************
42 * Class ComponentSignalNameListModel
43 ******************************************************************************/
44
49 : public QObject,
50 public slint::Model<slint::SharedString> {
51 Q_OBJECT
52
53public:
54 // Constructors / Destructor
55 // ComponentSignalNameListModel() = delete;
57 delete;
58 explicit ComponentSignalNameListModel(QObject* parent = nullptr) noexcept;
60
61 // General Methods
62 void setReferences(ComponentSignalList* list, UndoStack* stack) noexcept;
63 std::optional<Uuid> getUuid(std::size_t i) const noexcept;
64 int getIndexOf(const std::optional<Uuid>& sig) const noexcept;
65
66 // Implementations
67 std::size_t row_count() const override;
68 std::optional<slint::SharedString> row_data(std::size_t i) const override;
69 void set_row_data(std::size_t i, const slint::SharedString& data) override;
70
71 // Operator Overloadings
73 const ComponentSignalNameListModel& rhs) = delete;
74
75signals:
76 void modified();
77
78private:
79 void updateItems() noexcept;
80 void listEdited(const ComponentSignalList& list, int index,
81 const std::shared_ptr<const ComponentSignal>& item,
82 ComponentSignalList::Event event) noexcept;
83 void execCmd(UndoCommand* cmd);
84
85private:
88
89 QList<std::shared_ptr<ComponentSignal>> mSignalsSorted;
90
91 // Slots
93};
94
95/*******************************************************************************
96 * End of File
97 ******************************************************************************/
98
99} // namespace editor
100} // namespace librepcb
101
102#endif
The ComponentSignal class represents one signal of a component.
Definition componentsignal.h:45
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The ComponentSignalNameListModel class.
Definition componentsignalnamelistmodel.h:50
QList< std::shared_ptr< ComponentSignal > > mSignalsSorted
Definition componentsignalnamelistmodel.h:89
ComponentSignalNameListModel(const ComponentSignalNameListModel &other)=delete
void execCmd(UndoCommand *cmd)
Definition componentsignalnamelistmodel.cpp:185
void set_row_data(std::size_t i, const slint::SharedString &data) override
Definition componentsignalnamelistmodel.cpp:117
void listEdited(const ComponentSignalList &list, int index, const std::shared_ptr< const ComponentSignal > &item, ComponentSignalList::Event event) noexcept
Definition componentsignalnamelistmodel.cpp:160
int getIndexOf(const std::optional< Uuid > &sig) const noexcept
Definition componentsignalnamelistmodel.cpp:87
std::optional< slint::SharedString > row_data(std::size_t i) const override
Definition componentsignalnamelistmodel.cpp:106
std::size_t row_count() const override
Definition componentsignalnamelistmodel.cpp:102
void setReferences(ComponentSignalList *list, UndoStack *stack) noexcept
Definition componentsignalnamelistmodel.cpp:60
void updateItems() noexcept
Definition componentsignalnamelistmodel.cpp:139
QPointer< UndoStack > mUndoStack
Definition componentsignalnamelistmodel.h:87
ComponentSignalList::OnEditedSlot mOnEditedSlot
Definition componentsignalnamelistmodel.h:92
ComponentSignalList * mList
Definition componentsignalnamelistmodel.h:86
std::optional< Uuid > getUuid(std::size_t i) const noexcept
Definition componentsignalnamelistmodel.cpp:78
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