LibrePCB Developers Documentation
Loading...
Searching...
No Matches
componentsymbolvariantitemlistmodel.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_COMPONENTSYMBOLVARIANTITEMLISTMODEL_H
21#define LIBREPCB_EDITOR_COMPONENTSYMBOLVARIANTITEMLISTMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30#include <memory>
31
32/*******************************************************************************
33 * Namespace / Forward Declarations
34 ******************************************************************************/
35namespace librepcb {
36namespace editor {
37
38class LibraryElementCache;
39class UndoCommand;
40class UndoCommandGroup;
41class UndoStack;
42
43/*******************************************************************************
44 * Class ComponentSymbolVariantItemListModel
45 ******************************************************************************/
46
50class ComponentSymbolVariantItemListModel final : public QAbstractTableModel {
51 Q_OBJECT
52
53public:
64
65 // Constructors / Destructor
68 const ComponentSymbolVariantItemListModel& other) = delete;
70 QObject* parent = nullptr) noexcept;
72
73 // Setters
75 void setSymbolsCache(
76 const std::shared_ptr<const LibraryElementCache>& cache) noexcept;
77 void setUndoStack(UndoStack* stack) noexcept;
78
79 // Slots
80 void add(const QPersistentModelIndex& itemIndex) noexcept;
81 void remove(const QPersistentModelIndex& itemIndex) noexcept;
82 void moveUp(const QPersistentModelIndex& itemIndex) noexcept;
83 void moveDown(const QPersistentModelIndex& itemIndex) noexcept;
84 void browse(const QPersistentModelIndex& itemIndex,
85 const Uuid& symbol) noexcept;
86
87 // Inherited from QAbstractItemModel
88 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
89 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
90 QVariant data(const QModelIndex& index,
91 int role = Qt::DisplayRole) const override;
92 QVariant headerData(int section, Qt::Orientation orientation,
93 int role = Qt::DisplayRole) const override;
94 Qt::ItemFlags flags(const QModelIndex& index) const override;
95 bool setData(const QModelIndex& index, const QVariant& value,
96 int role = Qt::EditRole) override;
97
98 // Operator Overloadings
100 const ComponentSymbolVariantItemListModel& rhs) noexcept;
101
102private:
104 void itemListEdited(
105 const ComponentSymbolVariantItemList& list, int index,
106 const std::shared_ptr<const ComponentSymbolVariantItem>& item,
107 ComponentSymbolVariantItemList::Event event) noexcept;
108 void execCmd(UndoCommand* cmd, bool updateSuffixes = true);
109
110private: // Data
115 QString mNewSuffix;
119
120 // Slots
122};
123
124/*******************************************************************************
125 * End of File
126 ******************************************************************************/
127
128} // namespace editor
129} // namespace librepcb
130
131#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The ComponentSymbolVariantItem class represents one symbol of a component symbol variant.
Definition componentsymbolvariantitem.h:54
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The ComponentSymbolVariantItemListModel class.
Definition componentsymbolvariantitemlistmodel.h:50
void browse(const QPersistentModelIndex &itemIndex, const Uuid &symbol) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:181
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition componentsymbolvariantitemlistmodel.cpp:347
Angle mNewRotation
Definition componentsymbolvariantitemlistmodel.h:118
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition componentsymbolvariantitemlistmodel.cpp:218
void moveDown(const QPersistentModelIndex &itemIndex) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:163
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition componentsymbolvariantitemlistmodel.cpp:384
std::unique_ptr< UndoCommandGroup > createSuffixUpdateCmd()
Definition componentsymbolvariantitemlistmodel.cpp:521
void setSymbolsCache(const std::shared_ptr< const LibraryElementCache > &cache) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:81
void add(const QPersistentModelIndex &itemIndex) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:97
ComponentSymbolVariantItemList * mItemList
Definition componentsymbolvariantitemlistmodel.h:111
ComponentSymbolVariantItemList::OnEditedSlot mOnEditedSlot
Definition componentsymbolvariantitemlistmodel.h:121
std::shared_ptr< const LibraryElementCache > mSymbolsCache
Definition componentsymbolvariantitemlistmodel.h:112
bool mNewIsRequired
Definition componentsymbolvariantitemlistmodel.h:116
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition componentsymbolvariantitemlistmodel.cpp:234
void setUndoStack(UndoStack *stack) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:88
void moveUp(const QPersistentModelIndex &itemIndex) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:145
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:130
void execCmd(UndoCommand *cmd, bool updateSuffixes=true)
Definition componentsymbolvariantitemlistmodel.cpp:493
Point mNewPosition
Definition componentsymbolvariantitemlistmodel.h:117
QString mNewSuffix
Definition componentsymbolvariantitemlistmodel.h:115
ComponentSymbolVariantItemListModel(const ComponentSymbolVariantItemListModel &other)=delete
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition componentsymbolvariantitemlistmodel.cpp:396
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition componentsymbolvariantitemlistmodel.cpp:226
UndoStack * mUndoStack
Definition componentsymbolvariantitemlistmodel.h:113
std::optional< Uuid > mNewSymbolUuid
Definition componentsymbolvariantitemlistmodel.h:114
Column
Definition componentsymbolvariantitemlistmodel.h:54
@ _COLUMN_COUNT
Definition componentsymbolvariantitemlistmodel.h:62
@ COLUMN_ISREQUIRED
Definition componentsymbolvariantitemlistmodel.h:57
@ COLUMN_SYMBOL
Definition componentsymbolvariantitemlistmodel.h:55
@ COLUMN_X
Definition componentsymbolvariantitemlistmodel.h:58
@ COLUMN_Y
Definition componentsymbolvariantitemlistmodel.h:59
@ COLUMN_ROTATION
Definition componentsymbolvariantitemlistmodel.h:60
@ COLUMN_ACTIONS
Definition componentsymbolvariantitemlistmodel.h:61
@ COLUMN_SUFFIX
Definition componentsymbolvariantitemlistmodel.h:56
void setItemList(ComponentSymbolVariantItemList *list) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:68
void itemListEdited(const ComponentSymbolVariantItemList &list, int index, const std::shared_ptr< const ComponentSymbolVariantItem > &item, ComponentSymbolVariantItemList::Event event) noexcept
Definition componentsymbolvariantitemlistmodel.cpp:467
Cache for fast access to library elements.
Definition libraryelementcache.h:55
The UndoCommandGroup class makes it possible to pack multiple undo commands together (it acts as a pa...
Definition undocommandgroup.h:44
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