LibrePCB Developers Documentation
componentsignallistmodel.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_COMPONENTSIGNALLISTMODEL_H
21#define LIBREPCB_EDITOR_COMPONENTSIGNALLISTMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34namespace editor {
35
36class UndoCommand;
37class UndoStack;
38
39/*******************************************************************************
40 * Class ComponentSignalListModel
41 ******************************************************************************/
42
46class ComponentSignalListModel final : public QAbstractTableModel {
47 Q_OBJECT
48
49public:
50 enum Column {
56 };
57
58 // Constructors / Destructor
61 explicit ComponentSignalListModel(QObject* parent = nullptr) noexcept;
62 ~ComponentSignalListModel() noexcept;
63
64 // Setters
65 void setSignalList(ComponentSignalList* list) noexcept;
66 void setUndoStack(UndoStack* stack) noexcept;
67
68 // Slots
69 void add(const QPersistentModelIndex& itemIndex) noexcept;
70 void remove(const QPersistentModelIndex& itemIndex) noexcept;
71
72 // Inherited from QAbstractItemModel
73 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
74 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
75 QVariant data(const QModelIndex& index,
76 int role = Qt::DisplayRole) const override;
77 QVariant headerData(int section, Qt::Orientation orientation,
78 int role = Qt::DisplayRole) const override;
79 Qt::ItemFlags flags(const QModelIndex& index) const override;
80 bool setData(const QModelIndex& index, const QVariant& value,
81 int role = Qt::EditRole) override;
82
83 // Operator Overloadings
85 const ComponentSignalListModel& rhs) noexcept;
86
87private:
88 void signalListEdited(const ComponentSignalList& list, int index,
89 const std::shared_ptr<const ComponentSignal>& signal,
90 ComponentSignalList::Event event) noexcept;
91 void execCmd(UndoCommand* cmd);
92 CircuitIdentifier validateNameOrThrow(const QString& name) const;
93 static QString cleanForcedNetName(const QString& name) noexcept;
94
95private: // Data
98 QString mNewName;
101
102 // Slots
104};
105
106/*******************************************************************************
107 * End of File
108 ******************************************************************************/
109
110} // namespace editor
111} // namespace librepcb
112
113#endif
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:45
The ComponentSignalListModel class.
Definition: componentsignallistmodel.h:46
QString mNewForcedNetName
Definition: componentsignallistmodel.h:100
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: componentsignallistmodel.cpp:219
QString mNewName
Definition: componentsignallistmodel.h:98
void execCmd(UndoCommand *cmd)
Definition: componentsignallistmodel.cpp:347
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentsignallistmodel.cpp:131
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: componentsignallistmodel.cpp:249
void add(const QPersistentModelIndex &itemIndex) noexcept
Definition: componentsignallistmodel.cpp:86
static QString cleanForcedNetName(const QString &name) noexcept
Definition: componentsignallistmodel.cpp:366
void setSignalList(ComponentSignalList *list) noexcept
Definition: componentsignallistmodel.cpp:61
bool mNewIsRequired
Definition: componentsignallistmodel.h:99
CircuitIdentifier validateNameOrThrow(const QString &name) const
Definition: componentsignallistmodel.cpp:356
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: componentsignallistmodel.cpp:145
void setUndoStack(UndoStack *stack) noexcept
Definition: componentsignallistmodel.cpp:78
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition: componentsignallistmodel.cpp:112
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: componentsignallistmodel.cpp:259
ComponentSignalListModel(const ComponentSignalListModel &other)=delete
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentsignallistmodel.cpp:138
ComponentSignalList::OnEditedSlot mOnEditedSlot
Definition: componentsignallistmodel.h:103
void signalListEdited(const ComponentSignalList &list, int index, const std::shared_ptr< const ComponentSignal > &signal, ComponentSignalList::Event event) noexcept
Definition: componentsignallistmodel.cpp:321
UndoStack * mUndoStack
Definition: componentsignallistmodel.h:97
ComponentSignalList * mSignalList
Definition: componentsignallistmodel.h:96
Column
Definition: componentsignallistmodel.h:50
@ _COLUMN_COUNT
Definition: componentsignallistmodel.h:55
@ COLUMN_ISREQUIRED
Definition: componentsignallistmodel.h:52
@ COLUMN_NAME
Definition: componentsignallistmodel.h:51
@ COLUMN_FORCEDNETNAME
Definition: componentsignallistmodel.h:53
@ COLUMN_ACTIONS
Definition: componentsignallistmodel.h:54
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
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:96