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  ******************************************************************************/
36 namespace librepcb {
37 namespace editor {
38 
39 class LibraryElementCache;
40 class UndoCommand;
41 class UndoStack;
42 
43 /*******************************************************************************
44  * Class ComponentPinSignalMapModel
45  ******************************************************************************/
46 
50 class ComponentPinSignalMapModel final : public QAbstractTableModel {
51  Q_OBJECT
52 
53 public:
54  enum Column {
60  };
61 
62  // Constructors / Destructor
63  ComponentPinSignalMapModel() = delete;
65  explicit ComponentPinSignalMapModel(QObject* parent = nullptr) noexcept;
66  ~ComponentPinSignalMapModel() 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
90  ComponentPinSignalMapModel& operator=(
91  const ComponentPinSignalMapModel& rhs) noexcept;
92 
93 private:
94  void symbolItemsEdited(
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 
108 private: // 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
void setUndoStack(UndoStack *stack) noexcept
Definition: componentpinsignalmapmodel.cpp:98
std::shared_ptr< const LibraryElementCache > mSymbolsCache
Definition: componentpinsignalmapmodel.h:111
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: componentpinsignalmapmodel.cpp:156
ComboBoxDelegate::Items mSignalComboBoxItems
Definition: componentpinsignalmapmodel.h:113
Definition: occmodel.cpp:77
Column
Definition: componentpinsignalmapmodel.h:54
Cache for fast access to library elements.
Definition: libraryelementcache.h:55
void autoAssignSignals() noexcept
Definition: componentpinsignalmapmodel.cpp:106
Definition: componentpinsignalmapmodel.h:56
ComboBoxDelegate::Items mDisplayTypeComboBoxItems
Definition: componentpinsignalmapmodel.h:114
Definition: componentpinsignalmapmodel.h:59
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition: componentsymbolvariantitem.h:54
The ComponentPinSignalMapModel class.
Definition: componentpinsignalmapmodel.h:50
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition: undostack.h:106
void getRowItem(int row, int &symbolItemIndex, std::shared_ptr< ComponentSymbolVariantItem > &symbolItem, std::shared_ptr< ComponentPinSignalMapItem > &mapItem) const noexcept
Definition: componentpinsignalmapmodel.cpp:388
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:46
Subclass of QStyledItemDelegate which uses QComboBox as item editor.
Definition: comboboxdelegate.h:42
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: componentpinsignalmapmodel.cpp:271
UndoStack * mUndoStack
Definition: componentpinsignalmapmodel.h:112
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:319
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: componentpinsignalmapmodel.cpp:251
The ComponentPinSignalMapItem class maps a symbol pin to a component signal.
Definition: componentpinsignalmap.h:50
void signalListEdited(const ComponentSignalList &list, int index, const std::shared_ptr< const ComponentSignal > &signal, ComponentSignalList::Event event) noexcept
Definition: componentpinsignalmapmodel.cpp:341
Definition: componentpinsignalmapmodel.h:57
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentpinsignalmapmodel.cpp:139
void setSignalList(const ComponentSignalList *list) noexcept
Definition: componentpinsignalmapmodel.cpp:86
void updateSignalComboBoxItems() noexcept
Definition: componentpinsignalmapmodel.cpp:373
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentpinsignalmapmodel.cpp:149
void setSymbolVariant(ComponentSymbolVariant *variant) noexcept
Definition: componentpinsignalmapmodel.cpp:67
The ComponentSymbolVariant class represents a symbol variant of a component.
Definition: componentsymbolvariant.h:53
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:45
Definition: componentpinsignalmapmodel.h:58
ComponentSymbolVariant * mSymbolVariant
Definition: componentpinsignalmapmodel.h:109
void setSymbolsCache(const std::shared_ptr< const LibraryElementCache > &cache) noexcept
Definition: componentpinsignalmapmodel.cpp:80
const ComponentSignalList * mSignals
Definition: componentpinsignalmapmodel.h:110
ComponentSymbolVariantItemList::OnEditedSlot mOnItemsEditedSlot
Definition: componentpinsignalmapmodel.h:117
void execCmd(UndoCommand *cmd)
Definition: componentpinsignalmapmodel.cpp:364
Definition: componentpinsignalmapmodel.h:55
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: componentpinsignalmapmodel.cpp:282