Your ROOT_URL in app.ini is http://git.osmesh.ru/ but you are visiting http://91.221.70.94:3000/MOS/OpenBoard/commit/db5c7ce7324033cb1fefb0ec6ea9f7cc85ff075d?style=split&whitespace=ignore-eol You should set ROOT_URL correctly, otherwise the web may not work correctly.

Correct deletion of delegate instance (error with Vido on MAC OS)

preferencesAboutTextFull
Anatoly Mihalchenko 13 years ago
parent 8f1f0d9cbb
commit db5c7ce732
  1. 30
      src/domain/UBGraphicsGroupContainerItem.cpp
  2. 3
      src/domain/UBGraphicsGroupContainerItem.h
  3. 22
      src/domain/UBGraphicsMediaItem.cpp
  4. 22
      src/domain/UBGraphicsPDFItem.cpp
  5. 3
      src/domain/UBGraphicsPDFItem.h
  6. 29
      src/domain/UBGraphicsPixmapItem.cpp
  7. 3
      src/domain/UBGraphicsPixmapItem.h
  8. 37
      src/domain/UBGraphicsProxyWidget.cpp
  9. 8
      src/domain/UBGraphicsProxyWidget.h
  10. 29
      src/domain/UBGraphicsStrokesGroup.cpp
  11. 2
      src/domain/UBGraphicsStrokesGroup.h
  12. 25
      src/domain/UBGraphicsSvgItem.cpp
  13. 3
      src/domain/UBGraphicsSvgItem.h
  14. 49
      src/domain/UBGraphicsTextItem.cpp
  15. 3
      src/domain/UBGraphicsTextItem.h
  16. 30
      src/domain/UBGraphicsWidgetItem.cpp
  17. 3
      src/domain/UBGraphicsWidgetItem.h
  18. 19
      src/domain/UBItem.cpp
  19. 22
      src/domain/UBItem.h
  20. 23
      src/tools/UBGraphicsCurtainItem.cpp
  21. 3
      src/tools/UBGraphicsCurtainItem.h
  22. 5
      src/tools/UBGraphicsCurtainItemDelegate.h

@ -16,8 +16,8 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsGroupContainerItemDelegate(this, 0); setDelegate(new UBGraphicsGroupContainerItemDelegate(this, 0));
mDelegate->init(); Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -32,8 +32,6 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem() UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem()
{ {
if (mDelegate)
delete mDelegate;
} }
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
@ -50,14 +48,14 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
//Check if group is allready rotatable or flippable //Check if group is allready rotatable or flippable
if (childItems().count()) { if (childItems().count()) {
if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) { if (UBGraphicsItem::isFlippable(this) && !UBGraphicsItem::isFlippable(item)) {
mDelegate->setFlippable(false); Delegate()->setFlippable(false);
} }
if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) { if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) {
mDelegate->setRotatable(false); Delegate()->setRotatable(false);
} }
} else { } else {
mDelegate->setFlippable(UBGraphicsItem::isFlippable(item)); Delegate()->setFlippable(UBGraphicsItem::isFlippable(item));
mDelegate->setRotatable(UBGraphicsItem::isRotatable(item)); Delegate()->setRotatable(UBGraphicsItem::isRotatable(item));
} }
// COMBINE // COMBINE
@ -207,12 +205,6 @@ void UBGraphicsGroupContainerItem::copyItemParameters(UBItem *copy) const
} }
} }
void UBGraphicsGroupContainerItem::remove()
{
if (mDelegate)
mDelegate->remove();
}
void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid) void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid)
{ {
UBItem::setUuid(pUuid); UBItem::setUuid(pUuid);
@ -244,7 +236,7 @@ void UBGraphicsGroupContainerItem::clearSource()
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) { if (Delegate()->mousePressEvent(event)) {
//NOOP //NOOP
} else { } else {
@ -257,7 +249,7 @@ void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *eve
void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) { if (Delegate()->mouseMoveEvent(event)) {
// NOOP; // NOOP;
} else { } else {
QGraphicsItem::mouseMoveEvent(event); QGraphicsItem::mouseMoveEvent(event);
@ -273,7 +265,7 @@ void UBGraphicsGroupContainerItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e
QVariant UBGraphicsGroupContainerItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsGroupContainerItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
foreach(QGraphicsItem *child, children()) foreach(QGraphicsItem *child, children())
{ {
@ -317,8 +309,8 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
break; break;
} }
} }
mDelegate->setFlippable(flippableNow); Delegate()->setFlippable(flippableNow);
mDelegate->setRotatable(rotatableNow); Delegate()->setRotatable(rotatableNow);
} }
} }

@ -22,13 +22,10 @@ public:
QRectF boundingRect() const; QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual UBCoreGraphicsScene *corescene(); virtual UBCoreGraphicsScene *corescene();
virtual UBGraphicsGroupContainerItem *deepCopy() const; virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
enum { Type = UBGraphicsItemType::groupContainerType }; enum { Type = UBGraphicsItemType::groupContainerType };
virtual int type() const virtual int type() const

@ -72,6 +72,10 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
update(); update();
mMediaObject = new Phonon::MediaObject(this); mMediaObject = new Phonon::MediaObject(this);
setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject));
Delegate()->init();
if (pMediaFileUrl.toLocalFile().contains("videos")) if (pMediaFileUrl.toLocalFile().contains("videos"))
{ {
mMediaType = mediaType_Video; mMediaType = mediaType_Video;
@ -116,18 +120,14 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
mSource = Phonon::MediaSource(pMediaFileUrl); mSource = Phonon::MediaSource(pMediaFileUrl);
mMediaObject->setCurrentSource(mSource); mMediaObject->setCurrentSource(mSource);
UBGraphicsMediaItemDelegate* itemDelegate = new UBGraphicsMediaItemDelegate(this, mMediaObject);
itemDelegate->init();
setDelegate(itemDelegate);
if (mediaType_Audio == mMediaType) if (mediaType_Audio == mMediaType)
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::ResizingHorizontally);
else else
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
connect(mDelegate, SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool))); connect(Delegate(), SIGNAL(showOnDisplayChanged(bool)), this, SLOT(showOnDisplayChanged(bool)));
connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasMediaChanged(bool))); connect(mMediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasMediaChanged(bool)));
} }
@ -220,7 +220,7 @@ void UBGraphicsMediaItem::hasMediaChanged(bool hasMedia)
{ {
Q_UNUSED(hasMedia); Q_UNUSED(hasMedia);
mMediaObject->seek(mInitialPos); mMediaObject->seek(mInitialPos);
UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(mDelegate); UBGraphicsMediaItemDelegate *med = dynamic_cast<UBGraphicsMediaItemDelegate *>(Delegate());
if (med) if (med)
med->updateTicker(initialPos()); med->updateTicker(initialPos());
} }
@ -289,9 +289,9 @@ void UBGraphicsMediaItem::copyItemParameters(UBItem *copy) const
void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate) if (Delegate())
{ {
mDelegate->mousePressEvent(event); Delegate()->mousePressEvent(event);
if (parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type()) if (parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
{ {
UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem()); UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem());
@ -304,7 +304,7 @@ void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
group->setCurrentItem(this); group->setCurrentItem(this);
this->setSelected(true); this->setSelected(true);
mDelegate->positionHandles(); Delegate()->positionHandles();
} }
} }

@ -28,21 +28,20 @@ UBGraphicsPDFItem::UBGraphicsPDFItem(PDFRenderer *renderer, int pageNumber, QGra
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); //deprecated
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::BackgroundItem)); //Necessary to set if we want z value to be assigned correctly
mDelegate = new UBGraphicsItemDelegate(this,0, true, false, false);
mDelegate->init(); setDelegate(new UBGraphicsItemDelegate(this,0, true, false, false));
Delegate()->init();
} }
UBGraphicsPDFItem::~UBGraphicsPDFItem() UBGraphicsPDFItem::~UBGraphicsPDFItem()
{ {
if (mDelegate)
delete mDelegate;
} }
QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsPDFItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return GraphicsPDFItem::itemChange(change, newValue); return GraphicsPDFItem::itemChange(change, newValue);
} }
@ -54,7 +53,7 @@ void UBGraphicsPDFItem::setUuid(const QUuid &pUuid)
void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
// NOOP // NOOP
} }
@ -67,7 +66,7 @@ void UBGraphicsPDFItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP // NOOP
} }
@ -80,7 +79,7 @@ void UBGraphicsPDFItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPDFItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
GraphicsPDFItem::mouseReleaseEvent(event); GraphicsPDFItem::mouseReleaseEvent(event);
} }
@ -131,13 +130,6 @@ UBGraphicsScene* UBGraphicsPDFItem::scene()
} }
void UBGraphicsPDFItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const UBGraphicsPixmapItem* UBGraphicsPDFItem::toPixmapItem() const
{ {
QPixmap pixmap(mRenderer->pageSizeF(mPageNumber).toSize()); QPixmap pixmap(mRenderer->pageSizeF(mPageNumber).toSize());

@ -47,10 +47,7 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const; virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -28,10 +28,10 @@
UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent) UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
: QGraphicsPixmapItem(parent) : QGraphicsPixmapItem(parent)
{ {
mDelegate = new UBGraphicsItemDelegate(this, 0, true); setDelegate(new UBGraphicsItemDelegate(this, 0, true));
mDelegate->init(); Delegate()->init();
mDelegate->setFlippable(true); Delegate()->setFlippable(true);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation); setTransformationMode(Qt::SmoothTransformation);
@ -44,13 +44,11 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
UBGraphicsPixmapItem::~UBGraphicsPixmapItem() UBGraphicsPixmapItem::~UBGraphicsPixmapItem()
{ {
if (mDelegate)
delete mDelegate;
} }
QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsPixmapItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsPixmapItem::itemChange(change, newValue); return QGraphicsPixmapItem::itemChange(change, newValue);
} }
@ -64,14 +62,14 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
QMimeData* pMime = new QMimeData(); QMimeData* pMime = new QMimeData();
pMime->setImageData(pixmap().toImage()); pMime->setImageData(pixmap().toImage());
mDelegate->setMimeData(pMime); Delegate()->setMimeData(pMime);
qreal k = (qreal)pixmap().width() / 100.0; qreal k = (qreal)pixmap().width() / 100.0;
QSize newSize((int)(pixmap().width() / k), (int)(pixmap().height() / k)); QSize newSize((int)(pixmap().width() / k), (int)(pixmap().height() / k));
mDelegate->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); Delegate()->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -83,7 +81,7 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -95,7 +93,7 @@ void UBGraphicsPixmapItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsPixmapItem::mouseReleaseEvent(event); QGraphicsPixmapItem::mouseReleaseEvent(event);
} }
@ -145,13 +143,6 @@ UBGraphicsScene* UBGraphicsPixmapItem::scene()
} }
void UBGraphicsPixmapItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsPixmapItem::setOpacity(qreal op) void UBGraphicsPixmapItem::setOpacity(qreal op)
{ {
QGraphicsPixmapItem::setOpacity(op); QGraphicsPixmapItem::setOpacity(op);

@ -44,14 +44,11 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity)
void setOpacity(qreal op); void setOpacity(qreal op);
qreal opacity() const; qreal opacity() const;
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -29,8 +29,9 @@ UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this,0, true, false, false); //UBGraphicsItemDelegate* delegate = new UBGraphicsItemDelegate(this,0, true, false, false);
mDelegate->init(); //delegate->init();
//setDelegate(delegate);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -40,8 +41,6 @@ UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
UBGraphicsProxyWidget::~UBGraphicsProxyWidget() UBGraphicsProxyWidget::~UBGraphicsProxyWidget()
{ {
if (mDelegate)
delete mDelegate;
} }
@ -67,7 +66,7 @@ QVariant UBGraphicsProxyWidget::itemChange(GraphicsItemChange change, const QVar
} }
} }
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsProxyWidget::itemChange(change, newValue); return QGraphicsProxyWidget::itemChange(change, newValue);
} }
@ -79,7 +78,7 @@ void UBGraphicsProxyWidget::setUuid(const QUuid &pUuid)
void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -95,7 +94,7 @@ void UBGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -108,13 +107,13 @@ void UBGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsProxyWidget::mouseReleaseEvent(event); QGraphicsProxyWidget::mouseReleaseEvent(event);
} }
void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event) void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
if( mDelegate->weelEvent(event) ) if( Delegate()->weelEvent(event) )
{ {
QGraphicsProxyWidget::wheelEvent(event); QGraphicsProxyWidget::wheelEvent(event);
event->accept(); event->accept();
@ -132,17 +131,6 @@ void UBGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
// NOOP // NOOP
} }
void UBGraphicsProxyWidget::setDelegate(UBGraphicsItemDelegate* pDelegate)
{
if (mDelegate)
{
delete mDelegate;
}
mDelegate = pDelegate;
}
void UBGraphicsProxyWidget::resize(qreal w, qreal h) void UBGraphicsProxyWidget::resize(qreal w, qreal h)
{ {
UBGraphicsProxyWidget::resize(QSizeF(w, h)); UBGraphicsProxyWidget::resize(QSizeF(w, h));
@ -177,8 +165,8 @@ void UBGraphicsProxyWidget::resize(const QSizeF & pSize)
QGraphicsProxyWidget::resize(size.width(), size.height()); QGraphicsProxyWidget::resize(size.width(), size.height());
if (widget()) if (widget())
widget()->resize(size.width(), size.height()); widget()->resize(size.width(), size.height());
if (mDelegate) if (Delegate())
mDelegate->positionHandles(); Delegate()->positionHandles();
if (scene()) if (scene())
scene()->setModified(true); scene()->setModified(true);
} }
@ -197,8 +185,3 @@ UBGraphicsScene* UBGraphicsProxyWidget::scene()
} }
void UBGraphicsProxyWidget::remove()
{
if (mDelegate)
mDelegate->remove(true);
}

@ -27,7 +27,6 @@ class UBGraphicsItemDelegate;
class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public UBResizableGraphicsItem, public UBGraphicsItem
{ {
public: public:
UBGraphicsProxyWidget(QGraphicsItem* parent = 0);
virtual ~UBGraphicsProxyWidget(); virtual ~UBGraphicsProxyWidget();
virtual void resize(qreal w, qreal h); virtual void resize(qreal w, qreal h);
@ -35,18 +34,13 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual QSizeF size() const; virtual QSizeF size() const;
void setDelegate(UBGraphicsItemDelegate* pDelegate);
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
protected: protected:
UBGraphicsProxyWidget(QGraphicsItem* parent = 0);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

@ -4,12 +4,14 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsItemGroup(parent) UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent)
:UBGraphicsItem(), QGraphicsItemGroup(parent)
{ {
mDelegate = new UBGraphicsItemDelegate(this, 0, true, true, false); setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
mDelegate->init(); Delegate()->init();
mDelegate->setFlippable(true); Delegate()->setFlippable(true);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
@ -22,9 +24,6 @@ UBGraphicsStrokesGroup::UBGraphicsStrokesGroup(QGraphicsItem *parent):QGraphicsI
UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup() UBGraphicsStrokesGroup::~UBGraphicsStrokesGroup()
{ {
if(mDelegate){
delete mDelegate;
}
} }
void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid) void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid)
@ -83,7 +82,7 @@ QColor UBGraphicsStrokesGroup::color(colorType pColorType) const
void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -95,7 +94,7 @@ void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -107,7 +106,7 @@ void UBGraphicsStrokesGroup::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsItemGroup::mouseReleaseEvent(event); QGraphicsItemGroup::mouseReleaseEvent(event);
} }
@ -144,12 +143,6 @@ void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
} }
} }
void UBGraphicsStrokesGroup::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
// Never draw the rubber band, we draw our custom selection with the DelegateFrame // Never draw the rubber band, we draw our custom selection with the DelegateFrame
@ -161,7 +154,7 @@ void UBGraphicsStrokesGroup::paint(QPainter *painter, const QStyleOptionGraphics
QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsStrokesGroup::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsItemGroup::itemChange(change, newValue); return QGraphicsItemGroup::itemChange(change, newValue);
} }

@ -21,8 +21,6 @@ public:
~UBGraphicsStrokesGroup(); ~UBGraphicsStrokesGroup();
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
enum { Type = UBGraphicsItemType::StrokeItemType }; enum { Type = UBGraphicsItemType::StrokeItemType };
virtual int type() const virtual int type() const
{ {

@ -53,10 +53,11 @@ void UBGraphicsSvgItem::init()
{ {
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
mDelegate = new UBGraphicsItemDelegate(this, 0, true, true, false); setDelegate(new UBGraphicsItemDelegate(this, 0, true, true, false));
mDelegate->init(); Delegate()->init();
mDelegate->setFlippable(true); Delegate()->setFlippable(true);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
@ -71,8 +72,6 @@ void UBGraphicsSvgItem::init()
UBGraphicsSvgItem::~UBGraphicsSvgItem() UBGraphicsSvgItem::~UBGraphicsSvgItem()
{ {
if (mDelegate)
delete mDelegate;
} }
@ -84,14 +83,14 @@ QByteArray UBGraphicsSvgItem::fileData() const
QVariant UBGraphicsSvgItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsSvgItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsSvgItem::itemChange(change, newValue); return QGraphicsSvgItem::itemChange(change, newValue);
} }
void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -104,7 +103,7 @@ void UBGraphicsSvgItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -117,7 +116,7 @@ void UBGraphicsSvgItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsSvgItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsSvgItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsSvgItem::mouseReleaseEvent(event); QGraphicsSvgItem::mouseReleaseEvent(event);
} }
@ -182,12 +181,6 @@ UBGraphicsScene* UBGraphicsSvgItem::scene()
} }
void UBGraphicsSvgItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const UBGraphicsPixmapItem* UBGraphicsSvgItem::toPixmapItem() const
{ {

@ -58,10 +58,7 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove();
virtual UBGraphicsPixmapItem* toPixmapItem() const; virtual UBGraphicsPixmapItem* toPixmapItem() const;
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -31,16 +31,17 @@
QColor UBGraphicsTextItem::lastUsedTextColor; QColor UBGraphicsTextItem::lastUsedTextColor;
UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent) UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
: QGraphicsTextItem(parent) : UBGraphicsItem()
, QGraphicsTextItem(parent)
, mMultiClickState(0) , mMultiClickState(0)
, mLastMousePressTime(QTime::currentTime()) , mLastMousePressTime(QTime::currentTime())
{ {
mDelegate = new UBGraphicsTextItemDelegate(this, 0); setDelegate(new UBGraphicsTextItemDelegate(this, 0));
mDelegate->init(); Delegate()->init();
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
mDelegate->setFlippable(false); Delegate()->setFlippable(false);
mDelegate->setRotatable(true); Delegate()->setRotatable(true);
mTypeTextHereLabel = tr("<Type Text Here>"); mTypeTextHereLabel = tr("<Type Text Here>");
@ -58,7 +59,7 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
setUuid(QUuid::createUuid()); setUuid(QUuid::createUuid());
connect(document(), SIGNAL(contentsChanged()), mDelegate, SLOT(contentsChanged())); connect(document(), SIGNAL(contentsChanged()), Delegate(), SLOT(contentsChanged()));
connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undoCommandAdded())); connect(document(), SIGNAL(undoCommandAdded()), this, SLOT(undoCommandAdded()));
connect(document()->documentLayout(), SIGNAL(documentSizeChanged(const QSizeF &)), connect(document()->documentLayout(), SIGNAL(documentSizeChanged(const QSizeF &)),
@ -68,18 +69,14 @@ UBGraphicsTextItem::UBGraphicsTextItem(QGraphicsItem * parent)
UBGraphicsTextItem::~UBGraphicsTextItem() UBGraphicsTextItem::~UBGraphicsTextItem()
{ {
if (mDelegate)
{
delete mDelegate;
}
} }
QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsTextItem::itemChange(GraphicsItemChange change, const QVariant &value)
{ {
QVariant newValue = value; QVariant newValue = value;
if(mDelegate) if(Delegate())
newValue = mDelegate->itemChange(change, value); newValue = Delegate()->itemChange(change, value);
return QGraphicsTextItem::itemChange(change, newValue); return QGraphicsTextItem::itemChange(change, newValue);
} }
@ -95,10 +92,10 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
return; return;
} }
if (mDelegate) if (Delegate())
{ {
mDelegate->mousePressEvent(event); Delegate()->mousePressEvent(event);
if (mDelegate && parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type()) if (Delegate() && parentItem() && UBGraphicsGroupContainerItem::Type == parentItem()->type())
{ {
UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem()); UBGraphicsGroupContainerItem *group = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(parentItem());
if (group) if (group)
@ -110,13 +107,13 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
} }
group->setCurrentItem(this); group->setCurrentItem(this);
this->setSelected(true); this->setSelected(true);
mDelegate->positionHandles(); Delegate()->positionHandles();
} }
} }
else else
{ {
mDelegate->getToolBarItem()->show(); Delegate()->getToolBarItem()->show();
} }
} }
@ -165,7 +162,7 @@ void UBGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!mDelegate || !mDelegate->mouseMoveEvent(event)) if (!Delegate() || !Delegate()->mouseMoveEvent(event))
{ {
QGraphicsTextItem::mouseMoveEvent(event); QGraphicsTextItem::mouseMoveEvent(event);
} }
@ -184,8 +181,8 @@ void UBGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (mMultiClickState == 1) if (mMultiClickState == 1)
{ {
if (mDelegate) if (Delegate())
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsTextItem::mouseReleaseEvent(event); QGraphicsTextItem::mouseReleaseEvent(event);
} }
@ -324,8 +321,8 @@ void UBGraphicsTextItem::resize(qreal w, qreal h)
setTextWidth(w); setTextWidth(w);
setTextHeight(h); setTextHeight(h);
if (mDelegate) if (Delegate())
mDelegate->positionHandles(); Delegate()->positionHandles();
} }
@ -347,12 +344,6 @@ void UBGraphicsTextItem::undoCommandAdded()
} }
void UBGraphicsTextItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsTextItem::documentSizeChanged(const QSizeF & newSize) void UBGraphicsTextItem::documentSizeChanged(const QSizeF & newSize)
{ {
resize(newSize.width(), newSize.height()); resize(newSize.width(), newSize.height());

@ -58,8 +58,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
virtual QSizeF size() const; virtual QSizeF size() const;
virtual void remove();
static QColor lastUsedTextColor; static QColor lastUsedTextColor;
QColor colorOnDarkBackground() const QColor colorOnDarkBackground() const
@ -81,7 +79,6 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
{ {
mColorOnLightBackground = pColorOnLightBackground; mColorOnLightBackground = pColorOnLightBackground;
} }
virtual UBGraphicsItemDelegate *Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -84,8 +84,8 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
viewPalette.setBrush(QPalette::Window, QBrush(Qt::transparent)); viewPalette.setBrush(QPalette::Window, QBrush(Qt::transparent));
setPalette(viewPalette); setPalette(viewPalette);
mDelegate = new UBGraphicsWidgetItemDelegate(this); setDelegate(new UBGraphicsWidgetItemDelegate(this));
mDelegate->init(); Delegate()->init();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
QGraphicsWebView::setAcceptHoverEvents(true); QGraphicsWebView::setAcceptHoverEvents(true);
@ -102,8 +102,8 @@ void UBGraphicsWidgetItem::initialize()
setMinimumSize(nominalSize()); setMinimumSize(nominalSize());
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); // Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); // Necessary to set if we want z value to be assigned correctly
if (mDelegate && mDelegate->frame() && resizable()) if (Delegate() && Delegate()->frame() && resizable())
mDelegate->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing); Delegate()->frame()->setOperationMode(UBGraphicsDelegateFrame::Resizing);
QPalette palette = page()->palette(); QPalette palette = page()->palette();
palette.setBrush(QPalette::Base, QBrush(Qt::transparent)); palette.setBrush(QPalette::Base, QBrush(Qt::transparent));
@ -262,12 +262,6 @@ void UBGraphicsWidgetItem::removeAllDatastoreEntries()
mDatastore.clear(); mDatastore.clear();
} }
void UBGraphicsWidgetItem::remove()
{
if (mDelegate)
mDelegate->remove();
}
void UBGraphicsWidgetItem::removeScript() void UBGraphicsWidgetItem::removeScript()
{ {
if (page() && page()->mainFrame()) if (page() && page()->mainFrame())
@ -512,7 +506,7 @@ void UBGraphicsWidgetItem::dropEvent(QGraphicsSceneDragDropEvent *event)
void UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (!mDelegate->mousePressEvent(event)) if (!Delegate()->mousePressEvent(event))
setSelected(true); /* forcing selection */ setSelected(true); /* forcing selection */
QGraphicsWebView::mousePressEvent(event); QGraphicsWebView::mousePressEvent(event);
@ -529,19 +523,19 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mShouldMoveWidget = false; mShouldMoveWidget = false;
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsWebView::mouseReleaseEvent(event); QGraphicsWebView::mouseReleaseEvent(event);
} }
void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
sendJSEnterEvent(); sendJSEnterEvent();
mDelegate->hoverEnterEvent(event); Delegate()->hoverEnterEvent(event);
} }
void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
sendJSLeaveEvent(); sendJSLeaveEvent();
mDelegate->hoverLeaveEvent(event); Delegate()->hoverLeaveEvent(event);
} }
void UBGraphicsWidgetItem::sendJSEnterEvent() void UBGraphicsWidgetItem::sendJSEnterEvent()
@ -630,7 +624,7 @@ void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok)
void UBGraphicsWidgetItem::wheelEvent(QGraphicsSceneWheelEvent *event) void UBGraphicsWidgetItem::wheelEvent(QGraphicsSceneWheelEvent *event)
{ {
if (mDelegate->weelEvent(event)) if (Delegate()->weelEvent(event))
{ {
QGraphicsWebView::wheelEvent(event); QGraphicsWebView::wheelEvent(event);
event->accept(); event->accept();
@ -647,7 +641,7 @@ QVariant UBGraphicsWidgetItem::itemChange(GraphicsItemChange change, const QVari
scene()->setActiveWindow(0); scene()->setActiveWindow(0);
} }
QVariant newValue = mDelegate->itemChange(change, value); QVariant newValue = Delegate()->itemChange(change, value);
return QGraphicsWebView::itemChange(change, newValue); return QGraphicsWebView::itemChange(change, newValue);
} }
@ -662,8 +656,8 @@ void UBGraphicsWidgetItem::resize(const QSizeF & pSize)
if (pSize != size()) { if (pSize != size()) {
QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height()); QGraphicsWebView::setMaximumSize(pSize.width(), pSize.height());
QGraphicsWebView::resize(pSize.width(), pSize.height()); QGraphicsWebView::resize(pSize.width(), pSize.height());
if (mDelegate) if (Delegate())
mDelegate->positionHandles(); Delegate()->positionHandles();
if (scene()) if (scene())
scene()->setModified(true); scene()->setModified(true);
} }

@ -57,8 +57,6 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
virtual void resize(const QSizeF & size); virtual void resize(const QSizeF & size);
virtual QSizeF size() const; virtual QSizeF size() const;
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
QUrl mainHtml(); QUrl mainHtml();
void loadMainHtml(); void loadMainHtml();
QUrl widgetUrl(); QUrl widgetUrl();
@ -82,7 +80,6 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
void removeDatastoreEntry(const QString& key); void removeDatastoreEntry(const QString& key);
void removeAllDatastoreEntries(); void removeAllDatastoreEntries();
virtual void remove();
void removeScript(); void removeScript();
void processDropEvent(QGraphicsSceneDragDropEvent *event); void processDropEvent(QGraphicsSceneDragDropEvent *event);

@ -38,6 +38,18 @@ UBItem::~UBItem()
// NOOP // NOOP
} }
UBGraphicsItem::~UBGraphicsItem()
{
if (mDelegate!=NULL)
delete mDelegate;
}
void UBGraphicsItem::setDelegate(UBGraphicsItemDelegate* delegate)
{
Q_ASSERT(mDelegate==NULL);
mDelegate = delegate;
}
void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value) void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value)
{ {
item->setZValue(value); item->setZValue(value);
@ -54,6 +66,13 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item)
return item->data(UBGraphicsItemData::ItemRotatable).toBool(); return item->data(UBGraphicsItemData::ItemRotatable).toBool();
} }
void UBGraphicsItem::remove()
{
if (Delegate())
Delegate()->remove(this);
}
UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem) UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem)
{ {
UBGraphicsItemDelegate *result = 0; UBGraphicsItemDelegate *result = 0;

@ -90,30 +90,30 @@ class UBItem
class UBGraphicsItem class UBGraphicsItem
{ {
protected: protected:
UBGraphicsItem() : mDelegate(NULL)
UBGraphicsItem() : mDelegate(0)
{
// NOOP
}
UBGraphicsItemDelegate* mDelegate;
virtual ~UBGraphicsItem()
{ {
// NOOP // NOOP
} }
virtual ~UBGraphicsItem();
void setDelegate(UBGraphicsItemDelegate* mDelegate);
public: public:
inline UBGraphicsItemDelegate *Delegate() const { return mDelegate; }
static void assignZValue(QGraphicsItem*, qreal value); static void assignZValue(QGraphicsItem*, qreal value);
static bool isRotatable(QGraphicsItem *item); static bool isRotatable(QGraphicsItem *item);
static bool isFlippable(QGraphicsItem *item); static bool isFlippable(QGraphicsItem *item);
static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem); static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem);
virtual UBGraphicsItemDelegate *Delegate() const = 0;
virtual void remove() = 0;
virtual void clearSource(){;} void remove();
virtual void clearSource(){}
private:
UBGraphicsItemDelegate* mDelegate;
}; };
#endif // UBITEM_H #endif // UBITEM_H

@ -37,8 +37,9 @@ const QColor UBGraphicsCurtainItem::sDarkBackgroundOpaqueControlColor = QColor(6
UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent) UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
: QGraphicsRectItem(parent) : QGraphicsRectItem(parent)
{ {
mDelegate = new UBGraphicsCurtainItemDelegate(this, 0); UBGraphicsCurtainItemDelegate* delegate = new UBGraphicsCurtainItemDelegate(this, 0);
mDelegate->init(); delegate->init();
setDelegate(delegate);
setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsSelectable, true);
@ -56,7 +57,6 @@ UBGraphicsCurtainItem::UBGraphicsCurtainItem(QGraphicsItem* parent)
UBGraphicsCurtainItem::~UBGraphicsCurtainItem() UBGraphicsCurtainItem::~UBGraphicsCurtainItem()
{ {
delete mDelegate;
} }
QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVariant &value)
@ -64,9 +64,9 @@ QVariant UBGraphicsCurtainItem::itemChange(GraphicsItemChange change, const QVar
QVariant newValue = value; QVariant newValue = value;
if (mDelegate) if (Delegate())
{ {
newValue = mDelegate->itemChange(change, value); newValue = Delegate()->itemChange(change, value);
} }
return QGraphicsRectItem::itemChange(change, newValue); return QGraphicsRectItem::itemChange(change, newValue);
@ -80,7 +80,7 @@ void UBGraphicsCurtainItem::setUuid(const QUuid &pUuid)
void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) if (Delegate()->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
@ -92,7 +92,7 @@ void UBGraphicsCurtainItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mouseMoveEvent(event)) if (Delegate()->mouseMoveEvent(event))
{ {
// NOOP; // NOOP;
} }
@ -104,7 +104,7 @@ void UBGraphicsCurtainItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsCurtainItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsCurtainItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
mDelegate->mouseReleaseEvent(event); Delegate()->mouseReleaseEvent(event);
QGraphicsRectItem::mouseReleaseEvent(event); QGraphicsRectItem::mouseReleaseEvent(event);
} }
@ -171,13 +171,6 @@ QColor UBGraphicsCurtainItem::opaqueControlColor() const
} }
void UBGraphicsCurtainItem::remove()
{
if (mDelegate)
mDelegate->remove(true);
}
void UBGraphicsCurtainItem::triggerRemovedSignal() void UBGraphicsCurtainItem::triggerRemovedSignal()
{ {
emit removed(); emit removed();

@ -44,11 +44,8 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void remove();
//TODO UB 4.x not nice ... //TODO UB 4.x not nice ...
void triggerRemovedSignal(); void triggerRemovedSignal();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
virtual void clearSource(){;} virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -40,13 +40,12 @@ class UBGraphicsCurtainItemDelegate : public UBGraphicsItemDelegate
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
virtual void positionHandles(); virtual void positionHandles();
virtual void init();
public slots: public slots:
virtual void remove(bool checked, bool canUndo = true); virtual void remove(bool checked, bool canUndo = true);
protected:
virtual void init();
}; };
#endif /* UBGRAPHICSCURTAINITEMDELEGATE_H_ */ #endif /* UBGRAPHICSCURTAINITEMDELEGATE_H_ */

Loading…
Cancel
Save