LibrePCB Developers Documentation
devicepadsignalmapmodel.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_LIBRARY_EDITOR_DEVICEPADSIGNALMAPMODEL_H
21 #define LIBREPCB_LIBRARY_EDITOR_DEVICEPADSIGNALMAPMODEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
30 
31 #include <QtCore>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class UndoStack;
39 
40 namespace library {
41 namespace editor {
42 
43 /*******************************************************************************
44  * Class DevicePadSignalMapModel
45  ******************************************************************************/
46 
50 class DevicePadSignalMapModel final : public QAbstractTableModel {
51  Q_OBJECT
52 
53 public:
55 
56  // Constructors / Destructor
57  DevicePadSignalMapModel() = delete;
58  DevicePadSignalMapModel(const DevicePadSignalMapModel& other) noexcept;
59  explicit DevicePadSignalMapModel(QObject* parent = nullptr) noexcept;
60  ~DevicePadSignalMapModel() noexcept;
61 
62  // Setters
63  void setPadSignalMap(DevicePadSignalMap* map) noexcept;
64  void setUndoStack(UndoStack* stack) noexcept;
65  void setSignalList(const ComponentSignalList& list) noexcept;
66  void setPadList(const PackagePadList& list) noexcept;
67 
68  // Inherited from QAbstractItemModel
69  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
70  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
71  QVariant data(const QModelIndex& index,
72  int role = Qt::DisplayRole) const override;
73  QVariant headerData(int section, Qt::Orientation orientation,
74  int role = Qt::DisplayRole) const override;
75  Qt::ItemFlags flags(const QModelIndex& index) const override;
76  bool setData(const QModelIndex& index, const QVariant& value,
77  int role = Qt::EditRole) override;
78 
79  // Operator Overloadings
81  const DevicePadSignalMapModel& rhs) noexcept;
82 
83 private:
84  void padSignalMapEdited(
85  const DevicePadSignalMap& map, int index,
86  const std::shared_ptr<const DevicePadSignalMapItem>& item,
87  DevicePadSignalMap::Event event) noexcept;
88  void execCmd(UndoCommand* cmd);
89  void updateComboBoxItems() noexcept;
90 
91 private: // Data
97 
98  // Slots
100 };
101 
102 /*******************************************************************************
103  * End of File
104  ******************************************************************************/
105 
106 } // namespace editor
107 } // namespace library
108 } // namespace librepcb
109 
110 #endif
void updateComboBoxItems() noexcept
Definition: devicepadsignalmapmodel.cpp:267
DevicePadSignalMap * mPadSignalMap
Definition: devicepadsignalmapmodel.h:92
ComponentSignalList mSignals
Definition: devicepadsignalmapmodel.h:94
DevicePadSignalMapModel & operator=(const DevicePadSignalMapModel &rhs) noexcept
UndoStack * mUndoStack
Definition: devicepadsignalmapmodel.h:93
DevicePadSignalMap::OnEditedSlot mOnEditedSlot
Definition: devicepadsignalmapmodel.h:99
Definition: airwiresbuilder.cpp:32
~DevicePadSignalMapModel() noexcept
Definition: devicepadsignalmapmodel.cpp:54
void padSignalMapEdited(const DevicePadSignalMap &map, int index, const std::shared_ptr< const DevicePadSignalMapItem > &item, DevicePadSignalMap::Event event) noexcept
Definition: devicepadsignalmapmodel.cpp:233
Definition: comboboxdelegate.h:53
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition: undostack.h:107
Column
Definition: devicepadsignalmapmodel.h:54
The DevicePadSignalMapModel class.
Definition: devicepadsignalmapmodel.h:50
PackagePadList mPads
Definition: devicepadsignalmapmodel.h:95
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: devicepadsignalmapmodel.cpp:197
void setSignalList(const ComponentSignalList &list) noexcept
Definition: devicepadsignalmapmodel.cpp:82
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:47
void setUndoStack(UndoStack *stack) noexcept
Definition: devicepadsignalmapmodel.cpp:78
void setPadList(const PackagePadList &list) noexcept
Definition: devicepadsignalmapmodel.cpp:90
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: devicepadsignalmapmodel.cpp:113
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: devicepadsignalmapmodel.cpp:99
void setPadSignalMap(DevicePadSignalMap *map) noexcept
Definition: devicepadsignalmapmodel.cpp:61
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: devicepadsignalmapmodel.cpp:106
ComboBoxDelegate::Items mComboBoxItems
Definition: devicepadsignalmapmodel.h:96
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: devicepadsignalmapmodel.cpp:163
The Slot class is used to receive signals from non-QObject derived classes.
Definition: signalslot.h:36
void execCmd(UndoCommand *cmd)
Definition: devicepadsignalmapmodel.cpp:258
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: devicepadsignalmapmodel.cpp:205