LibrePCB Developers Documentation
Loading...
Searching...
No Matches
packagepadlistmodel.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_PACKAGEPADLISTMODEL_H
21#define LIBREPCB_EDITOR_PACKAGEPADLISTMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34namespace editor {
35
36class UndoCommand;
37class UndoStack;
38
39/*******************************************************************************
40 * Class PackagePadListModel
41 ******************************************************************************/
42
46class PackagePadListModel final : public QAbstractTableModel {
47 Q_OBJECT
48
49public:
51
52 // Constructors / Destructor
55 explicit PackagePadListModel(QObject* parent = nullptr) noexcept;
56 ~PackagePadListModel() noexcept;
57
58 // Setters
59 void setPadList(PackagePadList* list) noexcept;
60 void setUndoStack(UndoStack* stack) noexcept;
61
62 // Slots
63 void add(const QPersistentModelIndex& itemIndex) noexcept;
64 void remove(const QPersistentModelIndex& itemIndex) noexcept;
65
66 // Inherited from QAbstractItemModel
67 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
68 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
69 QVariant data(const QModelIndex& index,
70 int role = Qt::DisplayRole) const override;
71 QVariant headerData(int section, Qt::Orientation orientation,
72 int role = Qt::DisplayRole) const override;
73 Qt::ItemFlags flags(const QModelIndex& index) const override;
74 bool setData(const QModelIndex& index, const QVariant& value,
75 int role = Qt::EditRole) override;
76
77 // Operator Overloadings
78 PackagePadListModel& operator=(const PackagePadListModel& rhs) noexcept;
79
80private:
81 void padListEdited(const PackagePadList& list, int index,
82 const std::shared_ptr<const PackagePad>& pad,
83 PackagePadList::Event event) noexcept;
84 void execCmd(UndoCommand* cmd);
85 CircuitIdentifier validateNameOrThrow(const QString& name) const;
86 QString getNextPadNameProposal() const noexcept;
87
88private: // Data
91 QString mNewName;
92
93 // Slots
95};
96
97/*******************************************************************************
98 * End of File
99 ******************************************************************************/
100
101} // namespace editor
102} // namespace librepcb
103
104#endif
The PackagePad class represents one logical pad of a package.
Definition packagepad.h:47
The PackagePadListModel class.
Definition packagepadlistmodel.h:46
PackagePadList * mPadList
Definition packagepadlistmodel.h:89
void padListEdited(const PackagePadList &list, int index, const std::shared_ptr< const PackagePad > &pad, PackagePadList::Event event) noexcept
Definition packagepadlistmodel.cpp:274
PackagePadList::OnEditedSlot mOnEditedSlot
Definition packagepadlistmodel.h:94
void setPadList(PackagePadList *list) noexcept
Definition packagepadlistmodel.cpp:59
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition packagepadlistmodel.cpp:187
QString mNewName
Definition packagepadlistmodel.h:91
void execCmd(UndoCommand *cmd)
Definition packagepadlistmodel.cpp:299
QString getNextPadNameProposal() const noexcept
Definition packagepadlistmodel.cpp:318
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition packagepadlistmodel.cpp:127
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition packagepadlistmodel.cpp:220
void add(const QPersistentModelIndex &itemIndex) noexcept
Definition packagepadlistmodel.cpp:83
PackagePadListModel(const PackagePadListModel &other)=delete
CircuitIdentifier validateNameOrThrow(const QString &name) const
Definition packagepadlistmodel.cpp:308
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition packagepadlistmodel.cpp:141
void setUndoStack(UndoStack *stack) noexcept
Definition packagepadlistmodel.cpp:75
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition packagepadlistmodel.cpp:108
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition packagepadlistmodel.cpp:228
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition packagepadlistmodel.cpp:134
UndoStack * mUndoStack
Definition packagepadlistmodel.h:90
Column
Definition packagepadlistmodel.h:50
@ _COLUMN_COUNT
Definition packagepadlistmodel.h:50
@ COLUMN_NAME
Definition packagepadlistmodel.h:50
@ COLUMN_ACTIONS
Definition packagepadlistmodel.h:50
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:76
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition circuitidentifier.h:95
Definition uuid.h:186