LibrePCB Developers Documentation
componentpinsignalmapmodel.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_COMPONENTPINSIGNALMAPMODEL_H
21#define LIBREPCB_EDITOR_COMPONENTPINSIGNALMAPMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../../modelview/comboboxdelegate.h"
27
30
31#include <QtCore>
32
33/*******************************************************************************
34 * Namespace / Forward Declarations
35 ******************************************************************************/
36namespace librepcb {
37namespace editor {
38
39class LibraryElementCache;
40class UndoCommand;
41class UndoStack;
42
43/*******************************************************************************
44 * Class ComponentPinSignalMapModel
45 ******************************************************************************/
46
50class ComponentPinSignalMapModel final : public QAbstractTableModel {
51 Q_OBJECT
52
53public:
54 enum Column {
60 };
61
62 // Constructors / Destructor
65 explicit ComponentPinSignalMapModel(QObject* parent = nullptr) noexcept;
67
68 // Setters
69 void setSymbolVariant(ComponentSymbolVariant* variant) noexcept;
70 void setSignalList(const ComponentSignalList* list) noexcept;
71 void setSymbolsCache(
72 const std::shared_ptr<const LibraryElementCache>& cache) noexcept;
73 void setUndoStack(UndoStack* stack) noexcept;
74
75 // General Methods
76 void autoAssignSignals() noexcept;
77
78 // Inherited from QAbstractItemModel
79 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
80 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
81 QVariant data(const QModelIndex& index,
82 int role = Qt::DisplayRole) const override;
83 QVariant headerData(int section, Qt::Orientation orientation,
84 int role = Qt::DisplayRole) const override;
85 Qt::ItemFlags flags(const QModelIndex& index) const override;
86 bool setData(const QModelIndex& index, const QVariant& value,
87 int role = Qt::EditRole) override;
88
89 // Operator Overloadings
91 const ComponentPinSignalMapModel& rhs) noexcept;
92
93private:
95 const ComponentSymbolVariantItemList& list, int index,
96 const std::shared_ptr<const ComponentSymbolVariantItem>& item,
97 ComponentSymbolVariantItemList::Event event) noexcept;
98 void signalListEdited(const ComponentSignalList& list, int index,
99 const std::shared_ptr<const ComponentSignal>& signal,
100 ComponentSignalList::Event event) noexcept;
101 void execCmd(UndoCommand* cmd);
102 void updateSignalComboBoxItems() noexcept;
103 void getRowItem(
104 int row, int& symbolItemIndex,
105 std::shared_ptr<ComponentSymbolVariantItem>& symbolItem,
106 std::shared_ptr<ComponentPinSignalMapItem>& mapItem) const noexcept;
107
108private: // Data
111 std::shared_ptr<const LibraryElementCache> mSymbolsCache;
115
116 // Slots
119};
120
121/*******************************************************************************
122 * End of File
123 ******************************************************************************/
124
125} // namespace editor
126} // namespace librepcb
127
128#endif
The ComponentPinSignalMapItem class maps a symbol pin to a component signal.
Definition: componentpinsignalmap.h:50
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:45
The ComponentSymbolVariant class represents a symbol variant of a component.
Definition: componentsymbolvariant.h:53
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition: componentsymbolvariantitem.h:54
Subclass of QStyledItemDelegate which uses QComboBox as item editor.
Definition: comboboxdelegate.h:42
The ComponentPinSignalMapModel class.
Definition: componentpinsignalmapmodel.h:50
void updateSignalComboBoxItems() noexcept
Definition: componentpinsignalmapmodel.cpp:384
ComponentPinSignalMapModel(const ComponentPinSignalMapModel &other)=delete
ComponentSignalList::OnEditedSlot mOnSignalsEditedSlot
Definition: componentpinsignalmapmodel.h:118
void symbolItemsEdited(const ComponentSymbolVariantItemList &list, int index, const std::shared_ptr< const ComponentSymbolVariantItem > &item, ComponentSymbolVariantItemList::Event event) noexcept
Definition: componentpinsignalmapmodel.cpp:330
void autoAssignSignals() noexcept
Definition: componentpinsignalmapmodel.cpp:107
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: componentpinsignalmapmodel.cpp:262
ComboBoxDelegate::Items mDisplayTypeComboBoxItems
Definition: componentpinsignalmapmodel.h:114
void execCmd(UndoCommand *cmd)
Definition: componentpinsignalmapmodel.cpp:375
void setSignalList(const ComponentSignalList *list) noexcept
Definition: componentpinsignalmapmodel.cpp:87
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentpinsignalmapmodel.cpp:150
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: componentpinsignalmapmodel.cpp:282
void setSymbolsCache(const std::shared_ptr< const LibraryElementCache > &cache) noexcept
Definition: componentpinsignalmapmodel.cpp:81
std::shared_ptr< const LibraryElementCache > mSymbolsCache
Definition: componentpinsignalmapmodel.h:111
ComponentSymbolVariant * mSymbolVariant
Definition: componentpinsignalmapmodel.h:109
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: componentpinsignalmapmodel.cpp:167
void setUndoStack(UndoStack *stack) noexcept
Definition: componentpinsignalmapmodel.cpp:99
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: componentpinsignalmapmodel.cpp:293
ComponentSymbolVariantItemList::OnEditedSlot mOnItemsEditedSlot
Definition: componentpinsignalmapmodel.h:117
const ComponentSignalList * mSignals
Definition: componentpinsignalmapmodel.h:110
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentpinsignalmapmodel.cpp:160
void signalListEdited(const ComponentSignalList &list, int index, const std::shared_ptr< const ComponentSignal > &signal, ComponentSignalList::Event event) noexcept
Definition: componentpinsignalmapmodel.cpp:352
UndoStack * mUndoStack
Definition: componentpinsignalmapmodel.h:112
void getRowItem(int row, int &symbolItemIndex, std::shared_ptr< ComponentSymbolVariantItem > &symbolItem, std::shared_ptr< ComponentPinSignalMapItem > &mapItem) const noexcept
Definition: componentpinsignalmapmodel.cpp:399
Column
Definition: componentpinsignalmapmodel.h:54
@ _COLUMN_COUNT
Definition: componentpinsignalmapmodel.h:59
@ COLUMN_SYMBOL
Definition: componentpinsignalmapmodel.h:55
@ COLUMN_PIN
Definition: componentpinsignalmapmodel.h:56
@ COLUMN_SIGNAL
Definition: componentpinsignalmapmodel.h:57
@ COLUMN_DISPLAY
Definition: componentpinsignalmapmodel.h:58
ComboBoxDelegate::Items mSignalComboBoxItems
Definition: componentpinsignalmapmodel.h:113
void setSymbolVariant(ComponentSymbolVariant *variant) noexcept
Definition: componentpinsignalmapmodel.cpp:68
Cache for fast access to library elements.
Definition: libraryelementcache.h:55
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