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_EDITOR_DEVICEPADSIGNALMAPMODEL_H
21#define LIBREPCB_EDITOR_DEVICEPADSIGNALMAPMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../modelview/comboboxdelegate.h"
27
31
32#include <QtCore>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38namespace editor {
39
40class UndoCommand;
41class UndoStack;
42
43/*******************************************************************************
44 * Class DevicePadSignalMapModel
45 ******************************************************************************/
46
50class DevicePadSignalMapModel final : public QAbstractTableModel {
51 Q_OBJECT
52
53public:
55
56 // Constructors / Destructor
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
83private:
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
91private: // Data
97
98 // Slots
100};
101
102/*******************************************************************************
103 * End of File
104 ******************************************************************************/
105
106} // namespace editor
107} // namespace librepcb
108
109#endif
The DevicePadSignalMapItem class.
Definition: devicepadsignalmap.h:42
Subclass of QStyledItemDelegate which uses QComboBox as item editor.
Definition: comboboxdelegate.h:42
The DevicePadSignalMapModel class.
Definition: devicepadsignalmapmodel.h:50
ComponentSignalList mSignals
Definition: devicepadsignalmapmodel.h:94
void setPadList(const PackagePadList &list) noexcept
Definition: devicepadsignalmapmodel.cpp:89
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: devicepadsignalmapmodel.cpp:162
void execCmd(UndoCommand *cmd)
Definition: devicepadsignalmapmodel.cpp:240
void padSignalMapEdited(const DevicePadSignalMap &map, int index, const std::shared_ptr< const DevicePadSignalMapItem > &item, DevicePadSignalMap::Event event) noexcept
Definition: devicepadsignalmapmodel.cpp:214
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: devicepadsignalmapmodel.cpp:98
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: devicepadsignalmapmodel.cpp:178
DevicePadSignalMapModel(const DevicePadSignalMapModel &other)=delete
void setPadSignalMap(DevicePadSignalMap *map) noexcept
Definition: devicepadsignalmapmodel.cpp:60
DevicePadSignalMap * mPadSignalMap
Definition: devicepadsignalmapmodel.h:92
ComboBoxDelegate::Items mComboBoxItems
Definition: devicepadsignalmapmodel.h:96
PackagePadList mPads
Definition: devicepadsignalmapmodel.h:95
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: devicepadsignalmapmodel.cpp:112
void setUndoStack(UndoStack *stack) noexcept
Definition: devicepadsignalmapmodel.cpp:77
DevicePadSignalMap::OnEditedSlot mOnEditedSlot
Definition: devicepadsignalmapmodel.h:99
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: devicepadsignalmapmodel.cpp:186
void setSignalList(const ComponentSignalList &list) noexcept
Definition: devicepadsignalmapmodel.cpp:81
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: devicepadsignalmapmodel.cpp:105
UndoStack * mUndoStack
Definition: devicepadsignalmapmodel.h:93
Column
Definition: devicepadsignalmapmodel.h:54
@ _COLUMN_COUNT
Definition: devicepadsignalmapmodel.h:54
@ COLUMN_SIGNAL
Definition: devicepadsignalmapmodel.h:54
@ COLUMN_PAD
Definition: devicepadsignalmapmodel.h:54
void updateComboBoxItems() noexcept
Definition: devicepadsignalmapmodel.cpp:249
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