26void setElementGeometry(
Element *item,
const QRectF &geometry)
28 item->
setPos(geometry.topLeft());
37 , m_operation(NoOperation)
50 m_moveByData = QPointF(dx, dy);
51 m_operation = MoveOperation;
57 m_newGeometry = geometry;
64 if (!m_item || m_operation == NoOperation) {
65 qCDebug(KDSME_VIEW) <<
"Invalid item or no operation requested";
69 switch (m_operation) {
71 m_item->setPos(m_item->pos() + m_moveByData);
73 case SetGeometryOperation:
74 m_oldGeometry = QRectF(m_item->pos(), QSizeF(m_item->width(), m_item->height()));
75 setElementGeometry(m_item.data(), m_newGeometry);
82 if (!m_item || m_operation == NoOperation) {
83 qCDebug(KDSME_VIEW) <<
"Invalid item or no operation requested";
87 switch (m_operation) {
89 m_item->setPos(m_item->pos() - m_moveByData);
91 case SetGeometryOperation:
92 setElementGeometry(m_item.data(), m_oldGeometry);
99 if (other->id() !=
id()) {
104 if (cmd->m_item != m_item || cmd->m_operation !=
m_operation) {
108 m_moveByData += cmd->m_moveByData;
109 m_newGeometry = cmd->m_newGeometry;
113void KDSME::ModifyElementCommand::updateText()
115 const QString itemLabel = m_item ? m_item->label() : tr(
"<Unknown>");
117 switch (m_operation) {
119 setText(tr(
"Moving item %1").arg(itemLabel));
121 case SetGeometryOperation:
122 setText(tr(
"Resizing item %1").arg(itemLabel));
void setPos(const QPointF &pos)
void setWidth(qreal width)
void setHeight(qreal height)
Command for modifying properties of KDSME::Element.
Q_INVOKABLE void moveBy(qreal dx, qreal dy)
ModifyElementCommand(Element *item, QUndoCommand *parent=nullptr)
bool mergeWith(const QUndoCommand *other) override
Q_INVOKABLE void setGeometry(const QRectF &geometry)