31 setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable|QGraphicsItem::ItemSendsGeometryChanges);
45 setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable|QGraphicsItem::ItemSendsGeometryChanges);
65 Q_UNUSED(option); Q_UNUSED(widget);
70 painter -> setRenderHint(QPainter::Antialiasing,
false);
71 painter -> setRenderHint(QPainter::TextAntialiasing,
false);
72 painter -> setRenderHint(QPainter::SmoothPixmapTransform,
false);
75 t.setStyle(Qt::DashLine);
88 if (
diagram() -> isReadOnly())
return;
111 return (QRectF(
pixmap_.rect()));
123 return tr(
"une image");
134 if (e.tagName() !=
"image") {
138 QDomNode image_node = e.firstChild();
139 if (!image_node.isText()) {
145 array = QByteArray::fromBase64(e.text().toLatin1());
149 pixmap.loadFromData(array);
152 setScale(e.attribute(
"size").toDouble());
153 setRotation(e.attribute(
"rotation").toDouble());
155 QGraphicsObject::setPos(e.attribute(
"x").toDouble(), e.attribute(
"y").toDouble());
156 setZValue(e.attribute(
"z", QString::number(this->zValue())).toDouble());
167 QDomElement result = document.createElement(
"image");
169 result.setAttribute(
"x", QString::number(pos().x()));
170 result.setAttribute(
"y", QString::number(pos().y()));
171 result.setAttribute(
"z", QString::number(this->zValue()));
173 result.setAttribute(
"size", QString::number(scale()));
174 result.setAttribute(
"is_movable",
bool(
is_movable_));
178 QBuffer buffer(&array);
179 buffer.open(QIODevice::ReadWrite);
181 QDomText base64 = document.createTextNode(array.toBase64());
182 result.appendChild(base64);
~DiagramImageItem() override
DiagramImageItem::~DiagramImageItem Destructor.
QRectF boundingRect() const override
DiagramImageItem::boundingRect the outer bounds of the item as a rectangle, if no pixmap are set...
DiagramImageItem(QetGraphicsItem *=nullptr)
DiagramImageItem::DiagramImageItem Constructor without pixmap.
Diagram * diagram() const
QetGraphicsItem::diagram return the diagram of this item.
virtual bool fromXml(const QDomElement &)
DiagramImageItem::fromXml Load this image fro xml elemebt .
virtual QDomElement toXml(QDomDocument &) const
QString name() const override
DiagramImageItem::name.
void setPixmap(const QPixmap &pixmap)
DiagramImageItem::setPixmap Set the new pixmap to be draw.
The PropertiesEditorDialog class Create a dialog to edit some properties of a thing. Only create a instance of this class and call exec, all is done for you in this class. The first argument (a template) must be a subclass of QWidget and provide the 3 methods bellow : QString::title() void::apply() void::reset() You can subclass the interface PropertiesEditorWidget who provide all this methods. This dialog take ownership of the editor, so the editor will be deleted by this dialog.
qreal correctAngle(const qreal &)
void editProperty() override
DiagramImageItem::editProperty Open the approriate dialog to edit this image.
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
DiagramImageItem::paint Draw the pixmap.