#include <SchemaGraphicNote.hpp>
Definition at line 14 of file SchemaGraphicNote.hpp.
◆ SchemaGraphicNote()
| dbse::SchemaGraphicNote::SchemaGraphicNote |
( |
const QString & | name, |
|
|
const QString & | text, |
|
|
QGraphicsObject * | parent = nullptr ) |
|
explicit |
Definition at line 23 of file SchemaGraphicNote.cpp.
26 : QGraphicsObject (parent),
29
30 setAcceptHoverEvents(true);
31
32 setFlag ( ItemIsMovable );
33 setFlag ( ItemSendsGeometryChanges, true );
34 setFlag ( ItemSendsScenePositionChanges, true );
35
36}
◆ ~SchemaGraphicNote()
| dbse::SchemaGraphicNote::~SchemaGraphicNote |
( |
| ) |
|
|
default |
◆ boundingRect()
| QRectF dbse::SchemaGraphicNote::boundingRect |
( |
| ) |
const |
|
nodiscardoverride |
Definition at line 72 of file SchemaGraphicNote.cpp.
73{
75 double height = font_metrics.height()/2;
76 double width = 0;
77 for (
auto line:
m_text.split(
"\n")) {
78 height += font_metrics.height();
79 QRectF font_rect = font_metrics.boundingRect(line);
80 if (font_rect.width() > width) {
81 width = font_rect.width();
82 }
83 }
84 width += font_metrics.averageCharWidth()*2;
85
86 return QRectF(0, 0, width, height);
87
88}
static QFont get_font(const QString &group)
◆ mouseDoubleClickEvent()
| void dbse::SchemaGraphicNote::mouseDoubleClickEvent |
( |
QGraphicsSceneMouseEvent * | ev | ) |
|
|
overrideprotected |
◆ open_editor()
| void dbse::SchemaGraphicNote::open_editor |
( |
| ) |
|
Definition at line 38 of file SchemaGraphicNote.cpp.
38 {
39 bool editorFound = false;
40
41 for ( auto widget : QApplication::allWidgets() ) {
42 auto editor = dynamic_cast<SchemaNoteEditor*> (widget);
43 if ( editor != nullptr ) {
44 if ( (editor->objectName() ).compare (
m_name) == 0 ) {
45 editor->raise();
46 editor->setVisible ( true );
47 editor->activateWindow();
48 editorFound = true;
49 }
50 }
51 }
52
53 if ( !editorFound ) {
54 auto editor = new SchemaNoteEditor ( this );
55 editor->show();
56 }
57}
◆ paint()
| void dbse::SchemaGraphicNote::paint |
( |
QPainter * | painter, |
|
|
const QStyleOptionGraphicsItem * | option, |
|
|
QWidget * | widget ) |
|
override |
Definition at line 90 of file SchemaGraphicNote.cpp.
92 {
93
97 painter->setBrush (brush);
98
99 painter->setPen ( pen );
101 painter->drawRect ( rect );
102 painter->drawText(rect.adjusted(5,5,-2,-2), Qt::AlignJustify,
m_text);
103}
QRectF boundingRect() const override
static QColor get_color(const QString &item, const QString &group)
◆ shape()
| QPainterPath dbse::SchemaGraphicNote::shape |
( |
| ) |
const |
|
nodiscardoverride |
◆ text()
| QString dbse::SchemaGraphicNote::text |
( |
| ) |
|
|
inlinenodiscard |
◆ update_note()
| void dbse::SchemaGraphicNote::update_note |
( |
QString | text | ) |
|
Definition at line 64 of file SchemaGraphicNote.cpp.
64 {
65 auto this_scene = dynamic_cast<SchemaGraphicsScene*>(scene());
66 this_scene->remove_note_object(this);
68 this_scene->addItem(this);
70}
◆ updated
| void dbse::SchemaGraphicNote::updated |
( |
| ) |
|
|
signal |
◆ m_name
| QString dbse::SchemaGraphicNote::m_name |
|
private |
◆ m_text
| QString dbse::SchemaGraphicNote::m_text |
|
private |
The documentation for this class was generated from the following files: