LibrePCB Developers Documentation
Loading...
Searching...
No Matches
partlistmodel.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_PARTLISTMODEL_H
21#define LIBREPCB_EDITOR_PARTLISTMODEL_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 PartEditor;
39class UndoCommand;
40class UndoStack;
41
42/*******************************************************************************
43 * Class PartListModel
44 ******************************************************************************/
45
49class PartListModel final : public QObject, public slint::Model<ui::PartData> {
50 Q_OBJECT
51
52public:
53 // Constructors / Destructor
54 // PartListModel() = delete;
55 PartListModel(const PartListModel& other) = delete;
56 explicit PartListModel(QObject* parent = nullptr) noexcept;
57 ~PartListModel() noexcept;
58
59 // General Methods
60 void setDefaultManufacturer(const SimpleString& mfr) noexcept;
61 void setReferences(PartList* list, UndoStack* stack) noexcept;
62 void apply();
63
64 // Implementations
65 std::size_t row_count() const override;
66 std::optional<ui::PartData> row_data(std::size_t i) const override;
67 void set_row_data(std::size_t i, const ui::PartData& data) noexcept override;
68
69 // Operator Overloadings
70 PartListModel& operator=(const PartListModel& rhs) = delete;
71
72private:
73 void trigger(int index, std::shared_ptr<Part> obj, ui::PartAction a) noexcept;
74 void listEdited(const PartList& list, int index,
75 const std::shared_ptr<const Part>& item,
76 PartList::Event event) noexcept;
77 void execCmd(UndoCommand* cmd);
78
79private:
82 std::shared_ptr<Part> mNewPart;
83
84 QList<std::shared_ptr<PartEditor>> mItems;
85
86 // Slots
87 PartList::OnEditedSlot mOnEditedSlot;
88};
89
90/*******************************************************************************
91 * End of File
92 ******************************************************************************/
93
94} // namespace editor
95} // namespace librepcb
96
97#endif
The Part class.
Definition part.h:46
The PartEditor class.
Definition parteditor.h:50
The PartListModel class.
Definition partlistmodel.h:49
void set_row_data(std::size_t i, const ui::PartData &data) noexcept override
Definition partlistmodel.cpp:130
PartList::OnEditedSlot mOnEditedSlot
Definition partlistmodel.h:87
void execCmd(UndoCommand *cmd)
Definition partlistmodel.cpp:200
void setReferences(PartList *list, UndoStack *stack) noexcept
Definition partlistmodel.cpp:65
void trigger(int index, std::shared_ptr< Part > obj, ui::PartAction a) noexcept
Definition partlistmodel.cpp:152
std::size_t row_count() const override
Definition partlistmodel.cpp:118
void listEdited(const PartList &list, int index, const std::shared_ptr< const Part > &item, PartList::Event event) noexcept
Definition partlistmodel.cpp:172
std::optional< ui::PartData > row_data(std::size_t i) const override
Definition partlistmodel.cpp:122
PartList * mList
Definition partlistmodel.h:80
void apply()
Definition partlistmodel.cpp:91
QPointer< UndoStack > mUndoStack
Definition partlistmodel.h:81
std::shared_ptr< Part > mNewPart
Definition partlistmodel.h:82
QList< std::shared_ptr< PartEditor > > mItems
Definition partlistmodel.h:84
void setDefaultManufacturer(const SimpleString &mfr) noexcept
Definition partlistmodel.cpp:58
PartListModel(const PartListModel &other)=delete
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, SimpleStringConstraint, SimpleStringVerifier > SimpleString
Definition simplestring.h:79
Definition uuid.h:186