LibrePCB Developers Documentation
footprintlistmodel.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_FOOTPRINTLISTMODEL_H
21#define LIBREPCB_EDITOR_FOOTPRINTLISTMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class Package;
36
37namespace editor {
38
39class UndoCommand;
40class UndoStack;
41
42/*******************************************************************************
43 * Class FootprintListModel
44 ******************************************************************************/
45
49class FootprintListModel final : public QAbstractTableModel {
50 Q_OBJECT
51
52public:
53 enum Column {
63 };
64
65 // Constructors / Destructor
67 FootprintListModel(const FootprintListModel& other) = delete;
68 explicit FootprintListModel(QObject* parent = nullptr) noexcept;
69 ~FootprintListModel() noexcept;
70
71 // Setters
72 void setPackage(Package* package) noexcept;
73 void setUndoStack(UndoStack* stack) noexcept;
74
75 // Slots
76 void add(const QPersistentModelIndex& itemIndex) noexcept;
77 void copy(const QPersistentModelIndex& itemIndex) noexcept;
78 void remove(const QPersistentModelIndex& itemIndex) noexcept;
79 void moveUp(const QPersistentModelIndex& itemIndex) noexcept;
80 void moveDown(const QPersistentModelIndex& itemIndex) noexcept;
81
82 // Inherited from QAbstractItemModel
83 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
84 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
85 QVariant data(const QModelIndex& index,
86 int role = Qt::DisplayRole) const override;
87 QVariant headerData(int section, Qt::Orientation orientation,
88 int role = Qt::DisplayRole) const override;
89 Qt::ItemFlags flags(const QModelIndex& index) const override;
90 bool setData(const QModelIndex& index, const QVariant& value,
91 int role = Qt::EditRole) override;
92
93 // Operator Overloadings
94 FootprintListModel& operator=(const FootprintListModel& rhs) noexcept;
95
96private:
97 void footprintListEdited(const FootprintList& list, int index,
98 const std::shared_ptr<const Footprint>& footprint,
99 FootprintList::Event event) noexcept;
100 void execCmd(UndoCommand* cmd);
101 ElementName validateNameOrThrow(const QString& name) const;
102
103private: // Data
104 QPointer<Package> mPackage;
106 QString mNewName;
109
110 // Slots
112};
113
114/*******************************************************************************
115 * End of File
116 ******************************************************************************/
117
118} // namespace editor
119} // namespace librepcb
120
121#endif
The Footprint class represents one footprint variant of a package.
Definition: footprint.h:55
The Package class represents a package of a component (including footprint and 3D model)
Definition: package.h:59
The FootprintListModel class.
Definition: footprintlistmodel.h:49
Point3D mNewModelPosition
Definition: footprintlistmodel.h:107
QPointer< Package > mPackage
Definition: footprintlistmodel.h:104
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: footprintlistmodel.cpp:308
Angle3D mNewModelRotation
Definition: footprintlistmodel.h:108
void setPackage(Package *package) noexcept
Definition: footprintlistmodel.cpp:58
QString mNewName
Definition: footprintlistmodel.h:106
void execCmd(UndoCommand *cmd)
Definition: footprintlistmodel.cpp:450
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: footprintlistmodel.cpp:182
void moveDown(const QPersistentModelIndex &itemIndex) noexcept
Definition: footprintlistmodel.cpp:160
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: footprintlistmodel.cpp:355
void footprintListEdited(const FootprintList &list, int index, const std::shared_ptr< const Footprint > &footprint, FootprintList::Event event) noexcept
Definition: footprintlistmodel.cpp:424
void add(const QPersistentModelIndex &itemIndex) noexcept
Definition: footprintlistmodel.cpp:82
FootprintListModel(const FootprintListModel &other)=delete
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: footprintlistmodel.cpp:196
void copy(const QPersistentModelIndex &itemIndex) noexcept
Definition: footprintlistmodel.cpp:99
void setUndoStack(UndoStack *stack) noexcept
Definition: footprintlistmodel.cpp:74
void moveUp(const QPersistentModelIndex &itemIndex) noexcept
Definition: footprintlistmodel.cpp:142
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition: footprintlistmodel.cpp:127
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: footprintlistmodel.cpp:363
ElementName validateNameOrThrow(const QString &name) const
Definition: footprintlistmodel.cpp:459
FootprintList::OnEditedSlot mOnEditedSlot
Definition: footprintlistmodel.h:111
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: footprintlistmodel.cpp:189
UndoStack * mUndoStack
Definition: footprintlistmodel.h:105
Column
Definition: footprintlistmodel.h:53
@ _COLUMN_COUNT
Definition: footprintlistmodel.h:62
@ COLUMN_MODEL_POSITION_Z
Definition: footprintlistmodel.h:57
@ COLUMN_MODEL_ROTATION_Y
Definition: footprintlistmodel.h:59
@ COLUMN_NAME
Definition: footprintlistmodel.h:54
@ COLUMN_MODEL_ROTATION_X
Definition: footprintlistmodel.h:58
@ COLUMN_MODEL_POSITION_Y
Definition: footprintlistmodel.h:56
@ COLUMN_ACTIONS
Definition: footprintlistmodel.h:61
@ COLUMN_MODEL_ROTATION_Z
Definition: footprintlistmodel.h:60
@ COLUMN_MODEL_POSITION_X
Definition: footprintlistmodel.h:55
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:46
The UndoStack class holds UndoCommand objects and provides undo/redo commands.
Definition: undostack.h:106
Definition: occmodel.cpp:77
std::tuple< Length, Length, Length > Point3D
Definition: length.h:989
std::tuple< Angle, Angle, Angle > Angle3D
Definition: angle.h:461
type_safe::constrained_type< QString, ElementNameConstraint, ElementNameVerifier > ElementName
Definition: elementname.h:84