LibrePCB Developers Documentation
pathmodel.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_PATHMODEL_H
21#define LIBREPCB_EDITOR_PATHMODEL_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34namespace editor {
35
36/*******************************************************************************
37 * Class PathModel
38 ******************************************************************************/
39
43class PathModel final : public QAbstractTableModel {
44 Q_OBJECT
45
46public:
47 enum Column {
53 };
54
55 // Constructors / Destructor
56 PathModel() = delete;
57 PathModel(const PathModel& other) = delete;
58 explicit PathModel(QObject* parent = nullptr) noexcept;
59 ~PathModel() noexcept;
60
61 // Setters
62 void setPath(const Path& path) noexcept;
63 const Path& getPath() const noexcept { return mPath; }
64
65 // Slots
66 void add(const QPersistentModelIndex& itemIndex) noexcept;
67 void copy(const QPersistentModelIndex& itemIndex) noexcept;
68 void remove(const QPersistentModelIndex& itemIndex) noexcept;
69 void moveUp(const QPersistentModelIndex& itemIndex) noexcept;
70 void moveDown(const QPersistentModelIndex& itemIndex) noexcept;
71
72 // Inherited from QAbstractItemModel
73 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
74 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
75 QVariant data(const QModelIndex& index,
76 int role = Qt::DisplayRole) const override;
77 QVariant headerData(int section, Qt::Orientation orientation,
78 int role = Qt::DisplayRole) const override;
79 Qt::ItemFlags flags(const QModelIndex& index) const override;
80 bool setData(const QModelIndex& index, const QVariant& value,
81 int role = Qt::EditRole) override;
82
83 // Operator Overloadings
84 PathModel& operator=(const PathModel& rhs) noexcept;
85
86signals:
87 void pathChanged(const Path& path);
88
89private: // Data
92};
93
94/*******************************************************************************
95 * End of File
96 ******************************************************************************/
97
98} // namespace editor
99} // namespace librepcb
100
101#endif
The Path class represents a list of vertices connected by straight lines or circular arc segments.
Definition: path.h:58
The Vertex class.
Definition: vertex.h:44
The PathModel class implements QAbstractTableModel for librepcb::Path.
Definition: pathmodel.h:43
const Path & getPath() const noexcept
Definition: pathmodel.h:63
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: pathmodel.cpp:188
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: pathmodel.cpp:121
void moveDown(const QPersistentModelIndex &itemIndex) noexcept
Definition: pathmodel.cpp:105
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: pathmodel.cpp:222
void add(const QPersistentModelIndex &itemIndex) noexcept
Definition: pathmodel.cpp:62
PathModel(const PathModel &other)=delete
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: pathmodel.cpp:135
void copy(const QPersistentModelIndex &itemIndex) noexcept
Definition: pathmodel.cpp:71
void setPath(const Path &path) noexcept
Definition: pathmodel.cpp:49
void moveUp(const QPersistentModelIndex &itemIndex) noexcept
Definition: pathmodel.cpp:95
void remove(const QPersistentModelIndex &itemIndex) noexcept
Definition: pathmodel.cpp:83
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: pathmodel.cpp:230
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: pathmodel.cpp:128
PathModel & operator=(const PathModel &rhs) noexcept
Path mPath
Definition: pathmodel.h:90
Vertex mNewVertex
Definition: pathmodel.h:91
Column
Definition: pathmodel.h:47
@ _COLUMN_COUNT
Definition: pathmodel.h:52
@ COLUMN_X
Definition: pathmodel.h:48
@ COLUMN_Y
Definition: pathmodel.h:49
@ COLUMN_ANGLE
Definition: pathmodel.h:50
@ COLUMN_ACTIONS
Definition: pathmodel.h:51
void pathChanged(const Path &path)
Definition: occmodel.cpp:77