LibrePCB Developers Documentation
Loading...
Searching...
No Matches
attributelistmodellegacy.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_ATTRIBUTELISTMODELLEGACY_H
21#define LIBREPCB_EDITOR_ATTRIBUTELISTMODELLEGACY_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../modelview/comboboxdelegate.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 AttributeListModelLegacy
43 ******************************************************************************/
44
48class AttributeListModelLegacy final : public QAbstractTableModel {
49 Q_OBJECT
50
51public:
60
61 // Constructors / Destructor
64 explicit AttributeListModelLegacy(QObject* parent = nullptr) noexcept;
65 ~AttributeListModelLegacy() noexcept;
66
67 // Setters
68 void setAttributeList(AttributeList* list) noexcept;
69 void setUndoStack(UndoStack* stack) noexcept;
70
71 // Slots
72 void add(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 AttributeListModelLegacy& rhs) noexcept;
91
92private:
93 void attributeListEdited(const AttributeList& list, int index,
94 const std::shared_ptr<const Attribute>& attribute,
95 AttributeList::Event event) noexcept;
96 void execCmd(UndoCommand* cmd);
97 AttributeKey validateKeyOrThrow(const QString& key) const;
99 const AttributeType& type) noexcept;
100
101private: // Data
105 QString mNewKey;
107 QString mNewValue;
109
110 // Slots
112};
113
114/*******************************************************************************
115 * End of File
116 ******************************************************************************/
117
118} // namespace editor
119} // namespace librepcb
120
121#endif
The Attribute class.
Definition attribute.h:46
The AttributeType class.
Definition attributetype.h:42
The AttributeUnit class.
Definition attributeunit.h:40
The AttributeListModelLegacy class.
Definition attributelistmodellegacy.h:48
AttributeListModelLegacy(const AttributeListModelLegacy &other)=delete
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition attributelistmodellegacy.cpp:267
void attributeListEdited(const AttributeList &list, int index, const std::shared_ptr< const Attribute > &attribute, AttributeList::Event event) noexcept
Definition attributelistmodellegacy.cpp:395
void execCmd(UndoCommand *cmd)
Definition attributelistmodellegacy.cpp:421
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition attributelistmodellegacy.cpp:166
void moveDown(const QPersistentModelIndex &itemIndex) noexcept
Definition attributelistmodellegacy.cpp:145
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition attributelistmodellegacy.cpp:299
void setAttributeList(AttributeList *list) noexcept
Definition attributelistmodellegacy.cpp:69
void add(const QPersistentModelIndex &itemIndex) noexcept
Definition attributelistmodellegacy.cpp:93
const AttributeUnit * mNewUnit
Definition attributelistmodellegacy.h:108
QString mNewValue
Definition attributelistmodellegacy.h:107
AttributeKey validateKeyOrThrow(const QString &key) const
Definition attributelistmodellegacy.cpp:430
AttributeList * mAttributeList
Definition attributelistmodellegacy.h:102
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition attributelistmodellegacy.cpp:180
void setUndoStack(UndoStack *stack) noexcept
Definition attributelistmodellegacy.cpp:85
void moveUp(const QPersistentModelIndex &itemIndex) noexcept
Definition attributelistmodellegacy.cpp:128
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition attributelistmodellegacy.cpp:113
QString mNewKey
Definition attributelistmodellegacy.h:105
AttributeList::OnEditedSlot mOnEditedSlot
Definition attributelistmodellegacy.h:111
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition attributelistmodellegacy.cpp:315
ComboBoxDelegate::Items mTypeComboBoxItems
Definition attributelistmodellegacy.h:104
const AttributeType * mNewType
Definition attributelistmodellegacy.h:106
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition attributelistmodellegacy.cpp:173
UndoStack * mUndoStack
Definition attributelistmodellegacy.h:103
static ComboBoxDelegate::Items buildUnitComboBoxData(const AttributeType &type) noexcept
Definition attributelistmodellegacy.cpp:440
Column
Definition attributelistmodellegacy.h:52
@ COLUMN_TYPE
Definition attributelistmodellegacy.h:54
@ COLUMN_VALUE
Definition attributelistmodellegacy.h:55
@ _COLUMN_COUNT
Definition attributelistmodellegacy.h:58
@ COLUMN_KEY
Definition attributelistmodellegacy.h:53
@ COLUMN_UNIT
Definition attributelistmodellegacy.h:56
@ COLUMN_ACTIONS
Definition attributelistmodellegacy.h:57
Subclass of QStyledItemDelegate which uses QComboBox as item editor.
Definition comboboxdelegate.h:42
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