LibrePCB Developers Documentation
Loading...
Searching...
No Matches
assemblyvariantlistmodel.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_ASSEMBLYVARIANTLISTMODEL_H
21#define LIBREPCB_EDITOR_ASSEMBLYVARIANTLISTMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class Circuit;
36
37namespace editor {
38
39class UndoCommand;
40class UndoStack;
41
42/*******************************************************************************
43 * Class AssemblyVariantListModel
44 ******************************************************************************/
45
49class AssemblyVariantListModel final : public QAbstractTableModel {
50 Q_OBJECT
51
52public:
59
60 // Constructors / Destructor
63 explicit AssemblyVariantListModel(QObject* parent = nullptr) noexcept;
64 ~AssemblyVariantListModel() noexcept;
65
66 // Setters
67 void setCircuit(Circuit* circuit) noexcept;
68 void setUndoStack(UndoStack* stack) noexcept;
69 void setParentWidget(QWidget* widget) noexcept;
70
71 // Slots
72 void copy(const QPersistentModelIndex& itemIndex) noexcept;
73 void remove(const QPersistentModelIndex& itemIndex) noexcept;
74 void moveUp(const QPersistentModelIndex& itemIndex) noexcept;
75 void moveDown(const QPersistentModelIndex& itemIndex) noexcept;
76
77 // Inherited from QAbstractItemModel
78 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
79 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
80 QVariant data(const QModelIndex& index,
81 int role = Qt::DisplayRole) const override;
82 QVariant headerData(int section, Qt::Orientation orientation,
83 int role = Qt::DisplayRole) const override;
84 Qt::ItemFlags flags(const QModelIndex& index) const override;
85 bool setData(const QModelIndex& index, const QVariant& value,
86 int role = Qt::EditRole) override;
87
88 // Operator Overloadings
90 const AssemblyVariantListModel& rhs) noexcept;
91
92private:
93 void listEdited(const AssemblyVariantList& list, int index,
94 const std::shared_ptr<const AssemblyVariant>& obj,
95 AssemblyVariantList::Event event) noexcept;
96 void execCmd(UndoCommand* cmd);
97
98private: // Data
99 QPointer<QWidget> mParentWidget;
100 QPointer<Circuit> mCircuit;
102
103 // Slots
105};
106
107/*******************************************************************************
108 * End of File
109 ******************************************************************************/
110
111} // namespace editor
112} // namespace librepcb
113
114#endif
The AssemblyVariant class.
Definition assemblyvariant.h:44
The Circuit class represents all electrical connections in a project (drawn in the schematics)
Definition circuit.h:70
The AssemblyVariantListModel class.
Definition assemblyvariantlistmodel.h:49
void listEdited(const AssemblyVariantList &list, int index, const std::shared_ptr< const AssemblyVariant > &obj, AssemblyVariantList::Event event) noexcept
Definition assemblyvariantlistmodel.cpp:296
QPointer< Circuit > mCircuit
Definition assemblyvariantlistmodel.h:100
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition assemblyvariantlistmodel.cpp:219
void execCmd(UndoCommand *cmd)
Definition assemblyvariantlistmodel.cpp:322
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition assemblyvariantlistmodel.cpp:169
void moveDown(const QPersistentModelIndex &itemIndex) noexcept
Definition assemblyvariantlistmodel.cpp:148
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition assemblyvariantlistmodel.cpp:245
QPointer< QWidget > mParentWidget
Definition assemblyvariantlistmodel.h:99
AssemblyVariantListModel(const AssemblyVariantListModel &other)=delete
void setCircuit(Circuit *circuit) noexcept
Definition assemblyvariantlistmodel.cpp:61
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition assemblyvariantlistmodel.cpp:183
void copy(const QPersistentModelIndex &itemIndex) noexcept
Definition assemblyvariantlistmodel.cpp:89
void setUndoStack(UndoStack *stack) noexcept
Definition assemblyvariantlistmodel.cpp:77
void moveUp(const QPersistentModelIndex &itemIndex) noexcept
Definition assemblyvariantlistmodel.cpp:131
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition assemblyvariantlistmodel.cpp:114
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition assemblyvariantlistmodel.cpp:253
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition assemblyvariantlistmodel.cpp:176
UndoStack * mUndoStack
Definition assemblyvariantlistmodel.h:101
Column
Definition assemblyvariantlistmodel.h:53
@ _COLUMN_COUNT
Definition assemblyvariantlistmodel.h:57
@ COLUMN_DESCRIPTION
Definition assemblyvariantlistmodel.h:55
@ COLUMN_NAME
Definition assemblyvariantlistmodel.h:54
@ COLUMN_ACTIONS
Definition assemblyvariantlistmodel.h:56
void setParentWidget(QWidget *widget) noexcept
Definition assemblyvariantlistmodel.cpp:81
AssemblyVariantList::OnEditedSlot mOnEditedSlot
Definition assemblyvariantlistmodel.h:104
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
Definition uuid.h:186