Rectangle editor widget : use QPropertyUndoCommand instead of ChangePartCommand

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4064 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-07-22 13:19:43 +00:00
parent f24b1dd8d8
commit 6a902ca530
7 changed files with 115 additions and 151 deletions

View File

@@ -129,47 +129,7 @@ void PartRectangle::setRect(const QRectF &rect)
if (rect == m_rect) return;
prepareGeometryChange();
m_rect = rect;
}
/**
* @brief PartRectangle::rectTopLeft
* @return the rectangle top left in item coordinate
*/
QPointF PartRectangle::rectTopLeft() const {
return m_rect.topLeft();
}
/**
* @brief PartRectangle::setRectTopLeft
* @param point, set the rectangle top left in item coordinate.
* The rectangle size is unchanged
*/
void PartRectangle::setRectTopLeft(const QPointF &point) {
m_rect.moveTopLeft(point);
}
/**
* @brief PartRectangle::setWidth
* Sets the width of the rectangle to the given width.
* The right edge is changed, but not the left one.
* @param w new value
*/
void PartRectangle::setWidth(qreal w)
{
prepareGeometryChange();
m_rect.setWidth(qAbs(w));
}
/**
* @brief PartRectangle::setHeight
* Sets the height of the rectangle to the given height.
* The bottom edge is changed, but not the top one.
* @param h new value
*/
void PartRectangle::setHeight(qreal h)
{
prepareGeometryChange();
m_rect.setHeight(qAbs(h));
emit rectChanged();
}
/**

View File

@@ -32,10 +32,7 @@ class PartRectangle : public CustomElementGraphicPart
{
Q_OBJECT
Q_PROPERTY(QPointF rectTopLeft READ rectTopLeft WRITE setRectTopLeft)
Q_PROPERTY(qreal width READ width WRITE setWidth)
Q_PROPERTY(qreal height READ height WRITE setHeight)
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
Q_PROPERTY(QRectF rect READ rect WRITE setRect)
// constructors, destructor
public:
@@ -44,6 +41,9 @@ class PartRectangle : public CustomElementGraphicPart
private:
PartRectangle(const PartRectangle &);
signals:
void rectChanged();
// methods
public:
@@ -63,15 +63,6 @@ class PartRectangle : public CustomElementGraphicPart
QRectF rect() const;
void setRect(const QRectF &rect);
QPointF rectTopLeft () const;
void setRectTopLeft (const QPointF &point);
qreal width () const {return rect().width();}
void setWidth (qreal w);
qreal height () const { return rect().height();}
void setHeight (qreal h);
virtual QRectF sceneGeometricRect() const;
virtual QPointF sceneTopLeft() const;