LibrePCB Developers Documentation
textgraphicsitem.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_TEXTGRAPHICSITEM_H
21#define LIBREPCB_EDITOR_TEXTGRAPHICSITEM_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
27
28#include <QtCore>
29#include <QtWidgets>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35namespace editor {
36
37class IF_GraphicsLayerProvider;
38class OriginCrossGraphicsItem;
39class PrimitiveTextGraphicsItem;
40
41/*******************************************************************************
42 * Class TextGraphicsItem
43 ******************************************************************************/
44
49class TextGraphicsItem final : public QGraphicsItemGroup {
50public:
51 // Constructors / Destructor
52 TextGraphicsItem() = delete;
53 TextGraphicsItem(const TextGraphicsItem& other) = delete;
55 QGraphicsItem* parent = nullptr) noexcept;
56 virtual ~TextGraphicsItem() noexcept;
57
58 // Getters
59 Text& getObj() noexcept { return mText; }
60
61 // Setters
62 void setTextOverride(const tl::optional<QString>& text) noexcept;
63
64 // Inherited from QGraphicsItem
65 QPainterPath shape() const noexcept override;
66
67 // Operator Overloadings
68 TextGraphicsItem& operator=(const TextGraphicsItem& rhs) = delete;
69
70private: // Methods
71 void textEdited(const Text& text, Text::Event event) noexcept;
72 virtual QVariant itemChange(GraphicsItemChange change,
73 const QVariant& value) noexcept override;
74 void updateText() noexcept;
75
76private: // Data
79 tl::optional<QString> mTextOverride;
82
83 // Slots
84 Text::OnEditedSlot mOnEditedSlot;
85};
86
87/*******************************************************************************
88 * End of File
89 ******************************************************************************/
90
91} // namespace editor
92} // namespace librepcb
93
94#endif
The Text class.
Definition: text.h:48
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The OriginCrossGraphicsItem class.
Definition: origincrossgraphicsitem.h:50
The PrimitiveTextGraphicsItem class is the graphical representation of a text.
Definition: primitivetextgraphicsitem.h:52
The TextGraphicsItem class is the graphical representation of a librepcb::Text.
Definition: textgraphicsitem.h:49
QScopedPointer< OriginCrossGraphicsItem > mOriginCrossGraphicsItem
Definition: textgraphicsitem.h:81
void updateText() noexcept
Definition: textgraphicsitem.cpp:144
void textEdited(const Text &text, Text::Event event) noexcept
Definition: textgraphicsitem.cpp:115
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) noexcept override
Definition: textgraphicsitem.cpp:101
Text & mText
Definition: textgraphicsitem.h:77
QPainterPath shape() const noexcept override
Definition: textgraphicsitem.cpp:95
void setTextOverride(const tl::optional< QString > &text) noexcept
Definition: textgraphicsitem.cpp:83
QScopedPointer< PrimitiveTextGraphicsItem > mTextGraphicsItem
Definition: textgraphicsitem.h:80
const IF_GraphicsLayerProvider & mLayerProvider
Definition: textgraphicsitem.h:78
tl::optional< QString > mTextOverride
Definition: textgraphicsitem.h:79
TextGraphicsItem(const TextGraphicsItem &other)=delete
Text::OnEditedSlot mOnEditedSlot
Definition: textgraphicsitem.h:84
Text & getObj() noexcept
Definition: textgraphicsitem.h:59
Definition: occmodel.cpp:77
Definition: uuid.h:183