LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_COMPONENTPINSIGNALMAPMODEL_H
21 #define LIBREPCB_LIBRARY_COMPONENTPINSIGNALMAPMODEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "componentsignal.h"
27 #include "componentsymbolvariant.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class UndoStack;
37 
38 namespace library {
39 
40 class LibraryElementCache;
41 
42 /*******************************************************************************
43  * Class ComponentPinSignalMapModel
44  ******************************************************************************/
45 
49 class ComponentPinSignalMapModel final : public QAbstractTableModel {
50  Q_OBJECT
51 
52 public:
53  enum Column {
59  };
60 
61  // Constructors / Destructor
62  ComponentPinSignalMapModel() = delete;
64  explicit ComponentPinSignalMapModel(QObject* parent = nullptr) noexcept;
65  ~ComponentPinSignalMapModel() noexcept;
66 
67  // Setters
68  void setSymbolVariant(ComponentSymbolVariant* variant) noexcept;
69  void setSignalList(const ComponentSignalList* list) noexcept;
70  void setSymbolsCache(
71  const std::shared_ptr<const LibraryElementCache>& cache) noexcept;
72  void setUndoStack(UndoStack* stack) noexcept;
73 
74  // General Methods
75  void autoAssignSignals() noexcept;
76 
77  // Inherited from QAbstractItemModel
78  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
79  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
80  QVariant data(const QModelIndex& index,
81  int role = Qt::DisplayRole) const override;
82  QVariant headerData(int section, Qt::Orientation orientation,
83  int role = Qt::DisplayRole) const override;
84  Qt::ItemFlags flags(const QModelIndex& index) const override;
85  bool setData(const QModelIndex& index, const QVariant& value,
86  int role = Qt::EditRole) override;
87 
88  // Operator Overloadings
89  ComponentPinSignalMapModel& operator=(
90  const ComponentPinSignalMapModel& rhs) noexcept;
91 
92 private:
93  void symbolItemsEdited(
94  const ComponentSymbolVariantItemList& list, int index,
95  const std::shared_ptr<const ComponentSymbolVariantItem>& item,
96  ComponentSymbolVariantItemList::Event event) noexcept;
97  void signalListEdited(const ComponentSignalList& list, int index,
98  const std::shared_ptr<const ComponentSignal>& signal,
99  ComponentSignalList::Event event) noexcept;
100  void execCmd(UndoCommand* cmd);
101  void updateSignalComboBoxItems() noexcept;
102  void getRowItem(int row, int& symbolItemIndex,
103  std::shared_ptr<ComponentSymbolVariantItem>& symbolItem,
104  std::shared_ptr<ComponentPinSignalMapItem>& mapItem) const
105  noexcept;
106 
107 private: // Data
110  std::shared_ptr<const LibraryElementCache> mSymbolsCache;
112  QVector<QPair<QString, QVariant>> mSignalComboBoxItems;
113  QVector<QPair<QString, QVariant>> mDisplayTypeComboBoxItems;
114 
115  // Slots
118 };
119 
120 /*******************************************************************************
121  * End of File
122  ******************************************************************************/
123 
124 } // namespace library
125 } // namespace librepcb
126 
127 #endif // LIBREPCB_LIBRARY_COMPONENTPINSIGNALMAPMODEL_H
void updateSignalComboBoxItems() noexcept
Definition: componentpinsignalmapmodel.cpp:381
ComponentSymbolVariantItemList::OnEditedSlot mOnItemsEditedSlot
Definition: componentpinsignalmapmodel.h:116
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: componentpinsignalmapmodel.cpp:251
Definition: componentpinsignalmapmodel.h:54
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentpinsignalmapmodel.cpp:139
void autoAssignSignals() noexcept
Definition: componentpinsignalmapmodel.cpp:106
The ComponentSignal class represents one signal of a component.
Definition: componentsignal.h:49
QVector< QPair< QString, QVariant > > mDisplayTypeComboBoxItems
Definition: componentpinsignalmapmodel.h:113
Column
Definition: componentpinsignalmapmodel.h:53
void symbolItemsEdited(const ComponentSymbolVariantItemList &list, int index, const std::shared_ptr< const ComponentSymbolVariantItem > &item, ComponentSymbolVariantItemList::Event event) noexcept
Definition: componentpinsignalmapmodel.cpp:329
void getRowItem(int row, int &symbolItemIndex, std::shared_ptr< ComponentSymbolVariantItem > &symbolItem, std::shared_ptr< ComponentPinSignalMapItem > &mapItem) const noexcept
Definition: componentpinsignalmapmodel.cpp:402
void setSignalList(const ComponentSignalList *list) noexcept
Definition: componentpinsignalmapmodel.cpp:86
void setSymbolVariant(ComponentSymbolVariant *variant) noexcept
Definition: componentpinsignalmapmodel.cpp:67
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: componentpinsignalmapmodel.cpp:282
void execCmd(UndoCommand *cmd)
Definition: componentpinsignalmapmodel.cpp:372
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition: undostack.h:107
std::shared_ptr< const LibraryElementCache > mSymbolsCache
Definition: componentpinsignalmapmodel.h:110
Cache for fast access to library elements.
Definition: libraryelementcache.h:58
const ComponentSignalList * mSignals
Definition: componentpinsignalmapmodel.h:109
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:292
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: componentpinsignalmapmodel.cpp:156
void signalListEdited(const ComponentSignalList &list, int index, const std::shared_ptr< const ComponentSignal > &signal, ComponentSignalList::Event event) noexcept
Definition: componentpinsignalmapmodel.cpp:350
Definition: componentpinsignalmapmodel.h:55
Definition: componentpinsignalmapmodel.h:57
Definition: componentpinsignalmapmodel.h:56
UndoStack * mUndoStack
Definition: componentpinsignalmapmodel.h:111
The ComponentPinSignalMapModel class.
Definition: componentpinsignalmapmodel.h:49
ComponentSymbolVariant * mSymbolVariant
Definition: componentpinsignalmapmodel.h:108
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:47
void setUndoStack(UndoStack *stack) noexcept
Definition: componentpinsignalmapmodel.cpp:98
void setSymbolsCache(const std::shared_ptr< const LibraryElementCache > &cache) noexcept
Definition: componentpinsignalmapmodel.cpp:80
QVector< QPair< QString, QVariant > > mSignalComboBoxItems
Definition: componentpinsignalmapmodel.h:112
The ComponentSymbolVariant class represents a symbol variant of a component.
Definition: componentsymbolvariant.h:58
ComponentSignalList::OnEditedSlot mOnSignalsEditedSlot
Definition: componentpinsignalmapmodel.h:117
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition: componentsymbolvariantitem.h:58
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentpinsignalmapmodel.cpp:149
Definition: componentpinsignalmapmodel.h:58