LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_PATHMODEL_H
21 #define LIBREPCB_PATHMODEL_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "path.h"
27 
28 #include <QtCore>
29 
30 /*******************************************************************************
31  * Namespace / Forward Declarations
32  ******************************************************************************/
33 namespace librepcb {
34 
35 /*******************************************************************************
36  * Class PathModel
37  ******************************************************************************/
38 
42 class PathModel final : public QAbstractTableModel {
43  Q_OBJECT
44 
45 public:
46  enum Column {
52  };
53 
54  // Constructors / Destructor
55  PathModel() = delete;
56  PathModel(const PathModel& other) noexcept;
57  explicit PathModel(QObject* parent = nullptr) noexcept;
58  ~PathModel() noexcept;
59 
60  // Setters
61  void setPath(const Path& path) noexcept;
62  const Path& getPath() const noexcept { return mPath; }
63 
64  // Slots
65  void addItem(const QVariant& editData) noexcept;
66  void copyItem(const QVariant& editData) noexcept;
67  void removeItem(const QVariant& editData) noexcept;
68  void moveItemUp(const QVariant& editData) noexcept;
69  void moveItemDown(const QVariant& editData) noexcept;
70 
71  // Inherited from QAbstractItemModel
72  int rowCount(const QModelIndex& parent = QModelIndex()) const override;
73  int columnCount(const QModelIndex& parent = QModelIndex()) const override;
74  QVariant data(const QModelIndex& index,
75  int role = Qt::DisplayRole) const override;
76  QVariant headerData(int section, Qt::Orientation orientation,
77  int role = Qt::DisplayRole) const override;
78  Qt::ItemFlags flags(const QModelIndex& index) const override;
79  bool setData(const QModelIndex& index, const QVariant& value,
80  int role = Qt::EditRole) override;
81 
82  // Operator Overloadings
83  PathModel& operator=(const PathModel& rhs) noexcept;
84 
85 private: // Data
88 };
89 
90 /*******************************************************************************
91  * End of File
92  ******************************************************************************/
93 
94 } // namespace librepcb
95 
96 #endif // LIBREPCB_PATHMODEL_H
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Definition: pathmodel.cpp:232
void moveItemDown(const QVariant &editData) noexcept
Definition: pathmodel.cpp:96
PathModel & operator=(const PathModel &rhs) noexcept
The Vertex class.
Definition: vertex.h:43
Definition: pathmodel.h:48
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: pathmodel.cpp:181
const Path & getPath() const noexcept
Definition: pathmodel.h:62
Definition: pathmodel.h:51
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: pathmodel.cpp:111
void addItem(const QVariant &editData) noexcept
Definition: pathmodel.cpp:57
void removeItem(const QVariant &editData) noexcept
Definition: pathmodel.cpp:76
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: pathmodel.cpp:224
void copyItem(const QVariant &editData) noexcept
Definition: pathmodel.cpp:65
Definition: pathmodel.h:50
Definition: pathmodel.h:49
The PathModel class implements QAbstractTableModel for librepcb::Path.
Definition: pathmodel.h:42
void setPath(const Path &path) noexcept
Definition: pathmodel.cpp:47
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Definition: pathmodel.cpp:125
Column
Definition: pathmodel.h:46
Definition: pathmodel.h:47
The Path class represents a list of vertices connected by straight lines or circular arc segments...
Definition: path.h:53
void moveItemUp(const QVariant &editData) noexcept
Definition: pathmodel.cpp:87
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: pathmodel.cpp:118
Vertex mNewVertex
Definition: pathmodel.h:87
Path mPath
Definition: pathmodel.h:86