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