LibrePCB Developers Documentation
unplacedcomponentsdock.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_PROJECT_UNPLACEDCOMPONENTSDOCK_H
21 #define LIBREPCB_PROJECT_UNPLACEDCOMPONENTSDOCK_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 #include <librepcb/common/uuid.h>
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class GraphicsScene;
38 class DefaultGraphicsLayerProvider;
39 class UndoCommandGroup;
40 
41 namespace library {
42 class Device;
43 class Package;
44 class Footprint;
45 class FootprintPreviewGraphicsItem;
46 } // namespace library
47 
48 namespace project {
49 
50 class Project;
51 class Board;
52 class ComponentInstance;
53 
54 namespace editor {
55 
56 class ProjectEditor;
57 
58 namespace Ui {
59 class UnplacedComponentsDock;
60 }
61 
62 /*******************************************************************************
63  * Class SchematicPagesDock
64  ******************************************************************************/
65 
69 class UnplacedComponentsDock final : public QDockWidget {
70  Q_OBJECT
71 
72 public:
73  // Constructors / Destructor
74  explicit UnplacedComponentsDock(ProjectEditor& editor);
76 
77  // Getters
78  int getUnplacedComponentsCount() const noexcept;
79 
80  // Setters
81  void setBoard(Board* board);
82 
83 signals:
84 
85  void unplacedComponentsCountChanged(int count);
86  void addDeviceTriggered(ComponentInstance& cmp, const Uuid& deviceUuid,
87  Uuid footprintUuid);
88 
89 private slots:
90 
91  void on_lstUnplacedComponents_currentItemChanged(QListWidgetItem* current,
92  QListWidgetItem* previous);
93  void on_cbxSelectedDevice_currentIndexChanged(int index);
94  void on_cbxSelectedFootprint_currentIndexChanged(int index);
95  void on_btnAdd_clicked();
96  void on_pushButton_clicked();
97  void on_btnAddAll_clicked();
98 
99 private:
100  // make some methods inaccessible...
103  UnplacedComponentsDock& operator=(const UnplacedComponentsDock& rhs);
104 
105  // Private Methods
106  void updateComponentsList() noexcept;
107  void setSelectedComponentInstance(ComponentInstance* cmp) noexcept;
108  void setSelectedDeviceAndPackage(const library::Device* device,
109  const library::Package* package) noexcept;
110  void setSelectedFootprintUuid(const tl::optional<Uuid>& uuid) noexcept;
111  void beginUndoCmdGroup() noexcept;
112  void addNextDeviceToCmdGroup(
113  ComponentInstance& cmp, const Uuid& deviceUuid,
114  const tl::optional<Uuid>& footprintUuid) noexcept;
115  void commitUndoCmdGroup() noexcept;
116  void addDeviceManually(ComponentInstance& cmp, const Uuid& deviceUuid,
117  Uuid footprintUuid) noexcept;
118 
119  // General
123  Ui::UnplacedComponentsDock* mUi;
124  QScopedPointer<DefaultGraphicsLayerProvider> mGraphicsLayerProvider;
130  tl::optional<Uuid> mSelectedFootprintUuid;
131  QMetaObject::Connection mCircuitConnection1;
132  QMetaObject::Connection mCircuitConnection2;
133  QMetaObject::Connection mBoardConnection1;
134  QMetaObject::Connection mBoardConnection2;
137  QHash<Uuid, Uuid> mLastDeviceOfComponent;
138  QHash<Uuid, tl::optional<Uuid>> mLastFootprintOfDevice;
139  QScopedPointer<UndoCommandGroup> mCurrentUndoCmdGroup;
140 };
141 
142 /*******************************************************************************
143  * End of File
144  ******************************************************************************/
145 
146 } // namespace editor
147 } // namespace project
148 } // namespace librepcb
149 
150 #endif // LIBREPCB_PROJECT_UNPLACEDCOMPONENTSDOCK_H
library::FootprintPreviewGraphicsItem * mFootprintPreviewGraphicsItem
Definition: unplacedcomponentsdock.h:126
Definition: mainwindow.h:10
Definition: airwiresbuilder.cpp:32
The Package class represents a package of a component (including footprint and 3D model) ...
Definition: package.h:56
The Device class represents an instance of a component (a "real" component)
Definition: device.h:54
QHash< Uuid, Uuid > mLastDeviceOfComponent
Definition: unplacedcomponentsdock.h:137
The Project class represents a whole (opened) project with all its content.
Definition: project.h:80
The ProjectEditor class.
Definition: projecteditor.h:63
The FootprintPreviewGraphicsItem class.
Definition: footprintpreviewgraphicsitem.h:55
QMetaObject::Connection mCircuitConnection2
Definition: unplacedcomponentsdock.h:132
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
GraphicsScene * mFootprintPreviewGraphicsScene
Definition: unplacedcomponentsdock.h:125
Ui::UnplacedComponentsDock * mUi
Definition: unplacedcomponentsdock.h:123
bool mDisableListUpdate
Definition: unplacedcomponentsdock.h:136
ComponentInstance * mSelectedComponent
Definition: unplacedcomponentsdock.h:127
Point mNextPosition
Definition: unplacedcomponentsdock.h:135
const library::Device * mSelectedDevice
Definition: unplacedcomponentsdock.h:128
The UnplacedComponentsDock class.
Definition: unplacedcomponentsdock.h:69
QScopedPointer< UndoCommandGroup > mCurrentUndoCmdGroup
Definition: unplacedcomponentsdock.h:139
QScopedPointer< DefaultGraphicsLayerProvider > mGraphicsLayerProvider
Definition: unplacedcomponentsdock.h:124
tl::optional< Uuid > mSelectedFootprintUuid
Definition: unplacedcomponentsdock.h:130
ProjectEditor & mProjectEditor
Definition: unplacedcomponentsdock.h:120
const library::Package * mSelectedPackage
Definition: unplacedcomponentsdock.h:129
QMetaObject::Connection mCircuitConnection1
Definition: unplacedcomponentsdock.h:131
QMetaObject::Connection mBoardConnection2
Definition: unplacedcomponentsdock.h:134
QHash< Uuid, tl::optional< Uuid > > mLastFootprintOfDevice
Definition: unplacedcomponentsdock.h:138
The Board class represents a PCB of a project and is always part of a circuit.
Definition: board.h:83
QMetaObject::Connection mBoardConnection1
Definition: unplacedcomponentsdock.h:133
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
Board * mBoard
Definition: unplacedcomponentsdock.h:122
The GraphicsScene class.
Definition: graphicsscene.h:43
Project & mProject
Definition: unplacedcomponentsdock.h:121
The ComponentInstance class.
Definition: componentinstance.h:64