#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 20 of file SchemaGraphicNote.cpp.
23 : QGraphicsObject (parent),
26
27 setAcceptHoverEvents(true);
28 m_font = QFont(
"Helvetica [Cronyx]", 9);
29 m_bold_font = QFont(
"Helvetica [Cronyx]", 9, QFont::DemiBold);
33
34 setFlag ( ItemIsMovable );
35 setFlag ( ItemSendsGeometryChanges, true );
36 setFlag ( ItemSendsScenePositionChanges, true );
37
38}
QColor m_background_color
◆ ~SchemaGraphicNote()
dbse::SchemaGraphicNote::~SchemaGraphicNote |
( |
| ) |
|
|
default |
◆ boundingRect()
QRectF dbse::SchemaGraphicNote::boundingRect |
( |
| ) |
const |
|
nodiscardoverride |
Definition at line 74 of file SchemaGraphicNote.cpp.
75{
76 QFontMetrics font_metrics(
m_font);
77 double height = font_metrics.height()/2;
78 double width = 0;
79 for (
auto line:
m_text.split(
"\n")) {
80 height += font_metrics.height();
81 QRectF font_rect = font_metrics.boundingRect(line);
82 if (font_rect.width() > width) {
83 width = font_rect.width();
84 }
85 }
86 width += font_metrics.averageCharWidth()*2;
87
88 return QRectF(0, 0, width, height);
89
90}
◆ mouseDoubleClickEvent()
void dbse::SchemaGraphicNote::mouseDoubleClickEvent |
( |
QGraphicsSceneMouseEvent * | ev | ) |
|
|
overrideprotected |
◆ open_editor()
void dbse::SchemaGraphicNote::open_editor |
( |
| ) |
|
Definition at line 40 of file SchemaGraphicNote.cpp.
40 {
41 bool editorFound = false;
42
43 for ( auto widget : QApplication::allWidgets() ) {
44 auto editor = dynamic_cast<SchemaNoteEditor*> (widget);
45 if ( editor != nullptr ) {
46 if ( (editor->objectName() ).compare (
m_name) == 0 ) {
47 editor->raise();
48 editor->setVisible ( true );
49 editor->activateWindow();
50 editorFound = true;
51 }
52 }
53 }
54
55 if ( !editorFound ) {
56 auto editor = new SchemaNoteEditor ( this );
57 editor->show();
58 }
59}
◆ paint()
void dbse::SchemaGraphicNote::paint |
( |
QPainter * | painter, |
|
|
const QStyleOptionGraphicsItem * | option, |
|
|
QWidget * | widget ) |
|
override |
Definition at line 92 of file SchemaGraphicNote.cpp.
94 {
95
98 painter->setFont (
m_font );
99 painter->setBrush (brush);
100
101 painter->setPen ( pen );
103 painter->drawRect ( rect );
104 painter->drawText(rect.adjusted(5,5,-2,-2), Qt::AlignJustify,
m_text);
105}
QRectF boundingRect() const override
◆ 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 66 of file SchemaGraphicNote.cpp.
66 {
67 auto this_scene = dynamic_cast<SchemaGraphicsScene*>(scene());
68 this_scene->remove_note_object(this);
70 this_scene->addItem(this);
72}
◆ updated
void dbse::SchemaGraphicNote::updated |
( |
| ) |
|
|
signal |
◆ m_background_color
QColor dbse::SchemaGraphicNote::m_background_color |
|
private |
◆ m_bold_font
QFont dbse::SchemaGraphicNote::m_bold_font |
|
private |
◆ m_default_color
QColor dbse::SchemaGraphicNote::m_default_color |
|
private |
◆ m_font
QFont dbse::SchemaGraphicNote::m_font |
|
private |
◆ m_highlight_color
QColor dbse::SchemaGraphicNote::m_highlight_color |
|
private |
◆ 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: