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