LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
padsignalmapeditorwidget.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_PADSIGNALMAPEDITORWIDGET_H
21 #define LIBREPCB_LIBRARY_EDITOR_PADSIGNALMAPEDITORWIDGET_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class UndoStack;
39 
40 namespace workspace {
41 class Workspace;
42 }
43 
44 namespace library {
45 namespace editor {
46 
47 /*******************************************************************************
48  * Class PadSignalMapEditorWidget
49  ******************************************************************************/
50 
57 class PadSignalMapEditorWidget final : public QWidget,
58  private DevicePadSignalMap::IF_Observer {
59  Q_OBJECT
60 
61 private: // Types
63 
64 public:
65  // Constructors / Destructor
66  explicit PadSignalMapEditorWidget(QWidget* parent = nullptr) noexcept;
68  ~PadSignalMapEditorWidget() noexcept;
69 
70  // General Methods
71  void setReferences(UndoStack* undoStack, DevicePadSignalMap* map) noexcept;
72  void setPadList(const PackagePadList& list) noexcept;
73  void setSignalList(const ComponentSignalList& list) noexcept;
74 
75  // Operator Overloadings
76  PadSignalMapEditorWidget& operator=(const PadSignalMapEditorWidget& rhs) =
77  delete;
78 
79 private: // Slots
80  void currentCellChanged(int currentRow, int currentColumn, int previousRow,
81  int previousColumn) noexcept;
82  void componentSignalChanged(int index) noexcept;
83 
84 private: // Observer
85  void listObjectAdded(
86  const DevicePadSignalMap& list, int newIndex,
87  const std::shared_ptr<DevicePadSignalMapItem>& ptr) noexcept override;
88  void listObjectRemoved(
89  const DevicePadSignalMap& list, int oldIndex,
90  const std::shared_ptr<DevicePadSignalMapItem>& ptr) noexcept override;
91 
92 private: // Methods
93  void updateTable() noexcept;
94  void setTableRowContent(int row, const Uuid& padUuid, const QString& padName,
95  const tl::optional<Uuid>& signalUuid) noexcept;
96  void setComponentSignal(const Uuid& pad,
97  const tl::optional<Uuid>& signal) noexcept;
98  tl::optional<Uuid> getPadUuidOfTableCellWidget(QObject* obj) const noexcept;
99  tl::optional<Uuid> getPadUuidOfRow(int row) const noexcept;
100 
101 private: // Data
102  QTableWidget* mTable;
107  tl::optional<Uuid> mSelectedPad;
108 };
109 
110 /*******************************************************************************
111  * End of File
112  ******************************************************************************/
113 
114 } // namespace editor
115 } // namespace library
116 } // namespace librepcb
117 
118 #endif // LIBREPCB_LIBRARY_EDITOR_PADSIGNALMAPEDITORWIDGET_H
QTableWidget * mTable
Definition: padsignalmapeditorwidget.h:102
ComponentSignalList mSignals
Definition: padsignalmapeditorwidget.h:106
void setSignalList(const ComponentSignalList &list) noexcept
Definition: padsignalmapeditorwidget.cpp:106
void setPadList(const PackagePadList &list) noexcept
Definition: padsignalmapeditorwidget.cpp:101
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition: undostack.h:120
void listObjectAdded(const DevicePadSignalMap &list, int newIndex, const std::shared_ptr< DevicePadSignalMapItem > &ptr) noexceptoverride
Definition: padsignalmapeditorwidget.cpp:141
void setReferences(UndoStack *undoStack, DevicePadSignalMap *map) noexcept
Definition: padsignalmapeditorwidget.cpp:80
tl::optional< Uuid > mSelectedPad
Definition: padsignalmapeditorwidget.h:107
void updateTable() noexcept
Definition: padsignalmapeditorwidget.cpp:167
void listObjectRemoved(const DevicePadSignalMap &list, int oldIndex, const std::shared_ptr< DevicePadSignalMapItem > &ptr) noexceptoverride
Definition: padsignalmapeditorwidget.cpp:152
void currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) noexcept
Definition: padsignalmapeditorwidget.cpp:116
UndoStack * mUndoStack
Definition: padsignalmapeditorwidget.h:103
PackagePadList mPads
Definition: padsignalmapeditorwidget.h:105
The DevicePadSignalMapItem class.
Definition: devicepadsignalmap.h:46
void setComponentSignal(const Uuid &pad, const tl::optional< Uuid > &signal) noexcept
Definition: padsignalmapeditorwidget.cpp:260
PadSignalMapEditorWidget(QWidget *parent=nullptr) noexcept
Definition: padsignalmapeditorwidget.cpp:43
tl::optional< Uuid > getPadUuidOfRow(int row) const noexcept
Definition: padsignalmapeditorwidget.cpp:278
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
void setTableRowContent(int row, const Uuid &padUuid, const QString &padName, const tl::optional< Uuid > &signalUuid) noexcept
Definition: padsignalmapeditorwidget.cpp:210
Column
Definition: padsignalmapeditorwidget.h:62
DevicePadSignalMap * mPadSignalMap
Definition: padsignalmapeditorwidget.h:104
void componentSignalChanged(int index) noexcept
Definition: padsignalmapeditorwidget.cpp:126
The PadSignalMapEditorWidget class.
Definition: padsignalmapeditorwidget.h:57
tl::optional< Uuid > getPadUuidOfTableCellWidget(QObject *obj) const noexcept
Definition: padsignalmapeditorwidget.cpp:273