LibrePCB Developers Documentation
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/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34namespace editor {
35
36class LibraryElementCache;
37class UndoCommand;
38class UndoStack;
39
40/*******************************************************************************
41 * Class ComponentSymbolVariantItemListModel
42 ******************************************************************************/
43
47class ComponentSymbolVariantItemListModel final : public QAbstractTableModel {
48 Q_OBJECT
49
50public:
51 enum Column {
60 };
61
62 // Constructors / Destructor
65 const ComponentSymbolVariantItemListModel& other) = delete;
67 QObject* parent = nullptr) noexcept;
69
70 // Setters
72 void setSymbolsCache(
73 const std::shared_ptr<const LibraryElementCache>& cache) noexcept;
74 void setUndoStack(UndoStack* stack) noexcept;
75
76 // Slots
77 void add(const QPersistentModelIndex& itemIndex) noexcept;
78 void remove(const QPersistentModelIndex& itemIndex) noexcept;
79 void moveUp(const QPersistentModelIndex& itemIndex) noexcept;
80 void moveDown(const QPersistentModelIndex& itemIndex) noexcept;
81 void browse(const QPersistentModelIndex& itemIndex,
82 const Uuid& symbol) noexcept;
83
84 // Inherited from QAbstractItemModel
85 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
86 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
87 QVariant data(const QModelIndex& index,
88 int role = Qt::DisplayRole) const override;
89 QVariant headerData(int section, Qt::Orientation orientation,
90 int role = Qt::DisplayRole) const override;
91 Qt::ItemFlags flags(const QModelIndex& index) const override;
92 bool setData(const QModelIndex& index, const QVariant& value,
93 int role = Qt::EditRole) override;
94
95 // Operator Overloadings
97 const ComponentSymbolVariantItemListModel& rhs) noexcept;
98
99private:
100 void itemListEdited(
101 const ComponentSymbolVariantItemList& list, int index,
102 const std::shared_ptr<const ComponentSymbolVariantItem>& item,
103 ComponentSymbolVariantItemList::Event event) noexcept;
104 void execCmd(UndoCommand* cmd);
105
106private: // Data
108 std::shared_ptr<const LibraryElementCache> mSymbolsCache;
111 QString mNewSuffix;
115
116 // Slots
118};
119
120/*******************************************************************************
121 * End of File
122 ******************************************************************************/
123
124} // namespace editor
125} // namespace librepcb
126
127#endif
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
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:79
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The ComponentSymbolVariantItemListModel class.
Definition: componentsymbolvariantitemlistmodel.h:47
void browse(const QPersistentModelIndex &itemIndex, const Uuid &symbol) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:179
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: componentsymbolvariantitemlistmodel.cpp:345
void execCmd(UndoCommand *cmd)
Definition: componentsymbolvariantitemlistmodel.cpp:491
Angle mNewRotation
Definition: componentsymbolvariantitemlistmodel.h:114
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentsymbolvariantitemlistmodel.cpp:216
void moveDown(const QPersistentModelIndex &itemIndex) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:161
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: componentsymbolvariantitemlistmodel.cpp:382
void setSymbolsCache(const std::shared_ptr< const LibraryElementCache > &cache) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:80
void add(const QPersistentModelIndex &itemIndex) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:96
ComponentSymbolVariantItemList * mItemList
Definition: componentsymbolvariantitemlistmodel.h:107
ComponentSymbolVariantItemList::OnEditedSlot mOnEditedSlot
Definition: componentsymbolvariantitemlistmodel.h:117
std::shared_ptr< const LibraryElementCache > mSymbolsCache
Definition: componentsymbolvariantitemlistmodel.h:108
bool mNewIsRequired
Definition: componentsymbolvariantitemlistmodel.h:112
tl::optional< Uuid > mNewSymbolUuid
Definition: componentsymbolvariantitemlistmodel.h:110
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: componentsymbolvariantitemlistmodel.cpp:232
void setUndoStack(UndoStack *stack) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:87
void moveUp(const QPersistentModelIndex &itemIndex) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:143
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:128
Point mNewPosition
Definition: componentsymbolvariantitemlistmodel.h:113
QString mNewSuffix
Definition: componentsymbolvariantitemlistmodel.h:111
ComponentSymbolVariantItemListModel(const ComponentSymbolVariantItemListModel &other)=delete
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: componentsymbolvariantitemlistmodel.cpp:394
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: componentsymbolvariantitemlistmodel.cpp:224
UndoStack * mUndoStack
Definition: componentsymbolvariantitemlistmodel.h:109
Column
Definition: componentsymbolvariantitemlistmodel.h:51
@ _COLUMN_COUNT
Definition: componentsymbolvariantitemlistmodel.h:59
@ COLUMN_ISREQUIRED
Definition: componentsymbolvariantitemlistmodel.h:54
@ COLUMN_SYMBOL
Definition: componentsymbolvariantitemlistmodel.h:52
@ COLUMN_X
Definition: componentsymbolvariantitemlistmodel.h:55
@ COLUMN_Y
Definition: componentsymbolvariantitemlistmodel.h:56
@ COLUMN_ROTATION
Definition: componentsymbolvariantitemlistmodel.h:57
@ COLUMN_ACTIONS
Definition: componentsymbolvariantitemlistmodel.h:58
@ COLUMN_SUFFIX
Definition: componentsymbolvariantitemlistmodel.h:53
void setItemList(ComponentSymbolVariantItemList *list) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:67
void itemListEdited(const ComponentSymbolVariantItemList &list, int index, const std::shared_ptr< const ComponentSymbolVariantItem > &item, ComponentSymbolVariantItemList::Event event) noexcept
Definition: componentsymbolvariantitemlistmodel.cpp:465
Cache for fast access to library elements.
Definition: libraryelementcache.h:55
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
Definition: uuid.h:183