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 ******************************************************************************/
26#include "appwindow.h"
27
29
30#include <QtCore>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36namespace editor {
37
38class UndoCommand;
39class UndoStack;
40
41/*******************************************************************************
42 * Class PackagePadListModel
43 ******************************************************************************/
44
48class PackagePadListModel final : public QObject,
49 public slint::Model<ui::PackagePadData> {
50 Q_OBJECT
51
52public:
53 // Constructors / Destructor
54 // PackagePadListModel() = delete;
56 explicit PackagePadListModel(QObject* parent = nullptr) noexcept;
57 ~PackagePadListModel() noexcept;
58
59 // General Methods
60 void setReferences(PackagePadList* list, UndoStack* stack) noexcept;
61 bool add(QString names) noexcept;
62 void apply();
63
64 // Implementations
65 std::size_t row_count() const override;
66 std::optional<ui::PackagePadData> row_data(std::size_t i) const override;
67 void set_row_data(std::size_t i,
68 const ui::PackagePadData& data) noexcept override;
69
70 // Operator Overloadings
71 PackagePadListModel& operator=(const PackagePadListModel& rhs) = delete;
72
73private:
74 ui::PackagePadData createItem(const PackagePad& obj, int sortIndex) noexcept;
75 void updateSortOrder(bool notify) noexcept;
76 void listEdited(const PackagePadList& list, int index,
77 const std::shared_ptr<const PackagePad>& item,
78 PackagePadList::Event event) noexcept;
79 void execCmd(UndoCommand* cmd);
80 CircuitIdentifier validateNameOrThrow(const QString& name) const;
81 QString getNextPadNameProposal() const noexcept;
82
83private:
86
87 QList<ui::PackagePadData> mItems;
88
89 // Slots
91};
92
93/*******************************************************************************
94 * End of File
95 ******************************************************************************/
96
97} // namespace editor
98} // namespace librepcb
99
100#endif
The PackagePad class represents one logical pad of a package.
Definition packagepad.h:47
The PackagePadListModel class.
Definition packagepadlistmodel.h:49
PackagePadList::OnEditedSlot mOnEditedSlot
Definition packagepadlistmodel.h:90
QList< ui::PackagePadData > mItems
Definition packagepadlistmodel.h:87
PackagePadList * mList
Definition packagepadlistmodel.h:84
void execCmd(UndoCommand *cmd)
Definition packagepadlistmodel.cpp:247
QString getNextPadNameProposal() const noexcept
Definition packagepadlistmodel.cpp:266
void updateSortOrder(bool notify) noexcept
Definition packagepadlistmodel.cpp:193
ui::PackagePadData createItem(const PackagePad &obj, int sortIndex) noexcept
Definition packagepadlistmodel.cpp:182
std::optional< ui::PackagePadData > row_data(std::size_t i) const override
Definition packagepadlistmodel.cpp:140
PackagePadListModel(const PackagePadListModel &other)=delete
void setReferences(PackagePadList *list, UndoStack *stack) noexcept
Definition packagepadlistmodel.cpp:60
std::size_t row_count() const override
Definition packagepadlistmodel.cpp:136
void apply()
Definition packagepadlistmodel.cpp:110
CircuitIdentifier validateNameOrThrow(const QString &name) const
Definition packagepadlistmodel.cpp:256
bool add(QString names) noexcept
Definition packagepadlistmodel.cpp:85
QPointer< UndoStack > mUndoStack
Definition packagepadlistmodel.h:85
void listEdited(const PackagePadList &list, int index, const std::shared_ptr< const PackagePad > &item, PackagePadList::Event event) noexcept
Definition packagepadlistmodel.cpp:218
void set_row_data(std::size_t i, const ui::PackagePadData &data) noexcept override
Definition packagepadlistmodel.cpp:147
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
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition circuitidentifier.h:88
Definition uuid.h:186