mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Add and move terminal strip item are now managed by undo command
This commit is contained in:
@@ -47,3 +47,11 @@ QRectF TerminalStripItem::boundingRect() const
|
||||
|
||||
return br_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief TerminalStripItem::name
|
||||
* @return usual name of this item
|
||||
*/
|
||||
QString TerminalStripItem::name() const {
|
||||
return tr("plan de bornes");
|
||||
}
|
||||
|
||||
@@ -32,8 +32,12 @@ class TerminalStripItem : public QetGraphicsItem
|
||||
public:
|
||||
TerminalStripItem(QPointer<TerminalStrip> strip, QGraphicsItem *parent = nullptr);
|
||||
|
||||
enum {Type = UserType + 1011};
|
||||
int type() const override {return Type;}
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QRectF boundingRect() const override;
|
||||
QString name() const override;
|
||||
|
||||
private:
|
||||
QPointer<TerminalStrip> m_strip;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "addterminalstripitemdialog.h"
|
||||
#include "ui_addterminalstripitemdialog.h"
|
||||
|
||||
#include "../../undocommand/addgraphicsobjectcommand.h"
|
||||
#include "../terminalstrip.h"
|
||||
#include "../GraphicsItem/terminalstripitem.h"
|
||||
#include "../../diagram.h"
|
||||
@@ -32,7 +33,9 @@ void AddTerminalStripItemDialog::openDialog(Diagram *diagram, QWidget *parent)
|
||||
{
|
||||
auto item_ = new TerminalStripItem(strip_);
|
||||
diagram->addItem(item_);
|
||||
item_->setPos(20, 20);
|
||||
item_->setPos(50, 50);
|
||||
|
||||
diagram->project()->undoStack()->push(new AddGraphicsObjectCommand(item_, diagram, QPointF{50, 50}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,8 +63,8 @@ TerminalStrip *AddTerminalStripItemDialog::selectedTerminalStrip() const
|
||||
{
|
||||
if (m_project)
|
||||
{
|
||||
QUuid uuid_{ui->m_terminal_strip_cb->currentData().toUuid()};
|
||||
for (const auto &strip_ : m_project->terminalStrip())
|
||||
const QUuid uuid_{ui->m_terminal_strip_cb->currentData().toUuid()};
|
||||
for (auto &&strip_ : m_project->terminalStrip())
|
||||
{
|
||||
if (strip_->uuid() == uuid_) {
|
||||
return strip_;
|
||||
@@ -76,7 +79,7 @@ void AddTerminalStripItemDialog::fillComboBox()
|
||||
{
|
||||
if (m_project)
|
||||
{
|
||||
for (const auto strip_ : m_project->terminalStrip())
|
||||
for (auto &&strip_ : m_project->terminalStrip())
|
||||
{
|
||||
const auto text{strip_->installation() + " " + strip_->location() + " " + strip_->name()};
|
||||
ui->m_terminal_strip_cb->addItem(text, strip_->uuid());
|
||||
|
||||
Reference in New Issue
Block a user