LibrePCB Developers Documentation
Loading...
Searching...
No Matches
attributelistmodel.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_ATTRIBUTELISTMODEL_H
21#define LIBREPCB_EDITOR_ATTRIBUTELISTMODEL_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 AttributeListModel
43 ******************************************************************************/
44
48class AttributeListModel final : public QObject,
49 public slint::Model<ui::AttributeData> {
50 Q_OBJECT
51
52public:
53 // Constructors / Destructor
54 // AttributeListModel() = delete;
55 AttributeListModel(const AttributeListModel& other) = delete;
56 explicit AttributeListModel(QObject* parent = nullptr) noexcept;
57 ~AttributeListModel() noexcept;
58
59 // General Methods
60 void setReferences(AttributeList* list, UndoStack* stack) noexcept;
61 void apply();
62
63 // Implementations
64 std::size_t row_count() const override;
65 std::optional<ui::AttributeData> row_data(std::size_t i) const override;
66 void set_row_data(std::size_t i,
67 const ui::AttributeData& data) noexcept override;
68
69 // Operator Overloadings
70 AttributeListModel& operator=(const AttributeListModel& rhs) = delete;
71
72private:
73 ui::AttributeData createItem(const Attribute& obj) noexcept;
74 static ui::AttributeData createLastItem() noexcept;
75 void trigger(int index, std::shared_ptr<Attribute> obj,
76 ui::AttributeAction a) noexcept;
77 void listEdited(const AttributeList& list, int index,
78 const std::shared_ptr<const Attribute>& item,
79 AttributeList::Event event) noexcept;
80 void execCmd(UndoCommand* cmd);
81 AttributeKey validateKeyOrThrow(const QString& name) const;
82
83private:
86
87 QList<ui::AttributeData> mItems;
88
89 // Slots
91};
92
93/*******************************************************************************
94 * End of File
95 ******************************************************************************/
96
97} // namespace editor
98} // namespace librepcb
99
100#endif
The Attribute class.
Definition attribute.h:46
The AttributeListModel class.
Definition attributelistmodel.h:49
void setReferences(AttributeList *list, UndoStack *stack) noexcept
Definition attributelistmodel.cpp:60
AttributeKey validateKeyOrThrow(const QString &name) const
Definition attributelistmodel.cpp:314
AttributeList * mList
Definition attributelistmodel.h:84
void execCmd(UndoCommand *cmd)
Definition attributelistmodel.cpp:305
AttributeListModel(const AttributeListModel &other)=delete
std::size_t row_count() const override
Definition attributelistmodel.cpp:145
static ui::AttributeData createLastItem() noexcept
Definition attributelistmodel.cpp:248
void apply()
Definition attributelistmodel.cpp:87
QPointer< UndoStack > mUndoStack
Definition attributelistmodel.h:85
AttributeList::OnEditedSlot mOnEditedSlot
Definition attributelistmodel.h:90
void trigger(int index, std::shared_ptr< Attribute > obj, ui::AttributeAction a) noexcept
Definition attributelistmodel.cpp:261
QList< ui::AttributeData > mItems
Definition attributelistmodel.h:87
void set_row_data(std::size_t i, const ui::AttributeData &data) noexcept override
Definition attributelistmodel.cpp:156
void listEdited(const AttributeList &list, int index, const std::shared_ptr< const Attribute > &item, AttributeList::Event event) noexcept
Definition attributelistmodel.cpp:278
ui::AttributeData createItem(const Attribute &obj) noexcept
Definition attributelistmodel.cpp:233
std::optional< ui::AttributeData > row_data(std::size_t i) const override
Definition attributelistmodel.cpp:149
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, AttributeKeyConstraint, AttributeKeyVerifier > AttributeKey
Definition attributekey.h:78
Definition uuid.h:186