Reworked items copying mechanism.

Now coping creates a full copy of already created item. Copy has it's own content (like video, audio or folder) and stores original item properties (like locked, pos, size, freezed e.t.c.).
preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent 653201b63a
commit 81a49e9525
  1. 127
      src/board/UBBoardController.cpp
  2. 4
      src/board/UBBoardController.h
  3. 23
      src/domain/UBGraphicsGroupContainerItem.cpp
  4. 2
      src/domain/UBGraphicsGroupContainerItem.h
  5. 5
      src/domain/UBGraphicsItemDelegate.cpp
  6. 36
      src/domain/UBGraphicsMediaItem.cpp
  7. 2
      src/domain/UBGraphicsMediaItem.h
  8. 23
      src/domain/UBGraphicsPDFItem.cpp
  9. 2
      src/domain/UBGraphicsPDFItem.h
  10. 26
      src/domain/UBGraphicsPixmapItem.cpp
  11. 2
      src/domain/UBGraphicsPixmapItem.h
  12. 36
      src/domain/UBGraphicsPolygonItem.cpp
  13. 1
      src/domain/UBGraphicsPolygonItem.h
  14. 8
      src/domain/UBGraphicsScene.cpp
  15. 4
      src/domain/UBGraphicsScene.h
  16. 21
      src/domain/UBGraphicsStrokesGroup.cpp
  17. 1
      src/domain/UBGraphicsStrokesGroup.h
  18. 25
      src/domain/UBGraphicsSvgItem.cpp
  19. 2
      src/domain/UBGraphicsSvgItem.h
  20. 40
      src/domain/UBGraphicsTextItem.cpp
  21. 3
      src/domain/UBGraphicsTextItem.h
  22. 54
      src/domain/UBGraphicsWidgetItem.cpp
  23. 5
      src/domain/UBGraphicsWidgetItem.h
  24. 3
      src/domain/UBItem.h
  25. 15
      src/tools/UBGraphicsCache.cpp
  26. 2
      src/tools/UBGraphicsCache.h
  27. 15
      src/tools/UBGraphicsCompass.cpp
  28. 2
      src/tools/UBGraphicsCompass.h
  29. 24
      src/tools/UBGraphicsCurtainItem.cpp
  30. 1
      src/tools/UBGraphicsCurtainItem.h
  31. 23
      src/tools/UBGraphicsProtractor.cpp
  32. 1
      src/tools/UBGraphicsProtractor.h
  33. 15
      src/tools/UBGraphicsRuler.cpp
  34. 1
      src/tools/UBGraphicsRuler.h
  35. 15
      src/tools/UBGraphicsTriangle.cpp
  36. 1
      src/tools/UBGraphicsTriangle.h

@ -53,6 +53,7 @@
#include "domain/UBGraphicsTextItem.h" #include "domain/UBGraphicsTextItem.h"
#include "domain/UBPageSizeUndoCommand.h" #include "domain/UBPageSizeUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBItem.h"
#include "tools/UBToolsManager.h" #include "tools/UBToolsManager.h"
@ -529,6 +530,92 @@ void UBBoardController::duplicateScene()
duplicateScene(mActiveSceneIndex); duplicateScene(mActiveSceneIndex);
} }
void UBBoardController::duplicateItem(UBItem *item)
{
if (!item)
return;
QUrl sourceUrl;
QByteArray pData;
//common parameters for any item
QPointF itemPos;
QSizeF itemSize;
QGraphicsItem *commonItem = dynamic_cast<QGraphicsItem*>(item);
if (commonItem)
{
itemPos = commonItem->pos();
itemSize = commonItem->boundingRect().size();
}
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile());
UBMimeType::Enum itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader);
switch(static_cast<int>(itemMimeType))
{
case UBMimeType::AppleWidget:
case UBMimeType::W3CWidget:
{
UBGraphicsWidgetItem *witem = dynamic_cast<UBGraphicsWidgetItem*>(item);
if (witem)
{
sourceUrl = witem->getOwnFolder();
}
}break;
case UBMimeType::Video:
case UBMimeType::Audio:
{
UBGraphicsMediaItem *mitem = dynamic_cast<UBGraphicsMediaItem*>(item);
if (mitem)
{
sourceUrl = mitem->mediaFileUrl();
}
}break;
case UBMimeType::VectorImage:
{
UBGraphicsSvgItem *viitem = dynamic_cast<UBGraphicsSvgItem*>(item);
if (viitem)
{
pData = viitem->fileData();
sourceUrl = item->sourceUrl();
}
}break;
case UBMimeType::RasterImage:
{
UBGraphicsPixmapItem *pixitem = dynamic_cast<UBGraphicsPixmapItem*>(item);
if (pixitem)
{
QBuffer buffer(&pData);
buffer.open(QIODevice::WriteOnly);
QString format = UBFileSystemUtils::extension(item->sourceUrl().toLocalFile());
pixitem->pixmap().save(&buffer, format.toLatin1());
}
}break;
case UBMimeType::UNKNOWN:
{
QGraphicsItem *gitem = dynamic_cast<QGraphicsItem*>(item->deepCopy());
if (gitem)
{
mActiveScene->addItem(gitem);
gitem->setPos(itemPos);
}
return;
}break;
}
UBItem *createdItem = downloadFinished(true, sourceUrl, contentTypeHeader, pData, itemPos, QSize(itemSize.width(), itemSize.height()), false);
if (createdItem)
{
createdItem->setSourceUrl(item->sourceUrl());
item->copyItemParameters(createdItem);
}
}
void UBBoardController::deleteScene(int nIndex) void UBBoardController::deleteScene(int nIndex)
{ {
if (selectedDocument()->pageCount()>2) if (selectedDocument()->pageCount()>2)
@ -854,7 +941,7 @@ void UBBoardController::downloadURL(const QUrl& url, const QPointF& pPos, const
} }
void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground) UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString pContentTypeHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground)
{ {
QString mimeType = pContentTypeHeader; QString mimeType = pContentTypeHeader;
@ -869,7 +956,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
if (!pSuccess) if (!pSuccess)
{ {
UBApplication::showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString())); UBApplication::showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString()));
return; return NULL;
} }
if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://")) if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://"))
@ -897,12 +984,14 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
pixItem->setSelected(true); pixItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
return pixItem;
} }
else if (UBMimeType::VectorImage == itemMimeType) else if (UBMimeType::VectorImage == itemMimeType)
{ {
qDebug() << "accepting mime type" << mimeType << "as vecto image"; qDebug() << "accepting mime type" << mimeType << "as vecto image";
UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos); UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos, pData);
svgItem->setSourceUrl(sourceUrl); svgItem->setSourceUrl(sourceUrl);
if (isBackground) if (isBackground)
@ -915,6 +1004,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
svgItem->setSelected(true); svgItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
return svgItem;
} }
else if (UBMimeType::AppleWidget == itemMimeType) //mime type invented by us :-( else if (UBMimeType::AppleWidget == itemMimeType) //mime type invented by us :-(
{ {
@ -939,6 +1030,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
{ {
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
return appleWidgetItem;
} }
else if (UBMimeType::W3CWidget == itemMimeType) else if (UBMimeType::W3CWidget == itemMimeType)
{ {
@ -960,6 +1053,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
{ {
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
} }
return w3cWidgetItem;
} }
else if (UBMimeType::Video == itemMimeType) else if (UBMimeType::Video == itemMimeType)
{ {
@ -989,6 +1084,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
} }
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return mediaVideoItem;
} }
else if (UBMimeType::Audio == itemMimeType) else if (UBMimeType::Audio == itemMimeType)
{ {
@ -1018,6 +1115,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
} }
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return audioMediaItem;
} }
else if (UBMimeType::Flash == itemMimeType) else if (UBMimeType::Flash == itemMimeType)
@ -1061,6 +1160,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
widgetItem->setSourceUrl(sourceUrl); widgetItem->setSourceUrl(sourceUrl);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return widgetItem;
} }
if (eduMediaFile) if (eduMediaFile)
@ -1182,6 +1283,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
widgetItem->setSourceUrl(sourceUrl); widgetItem->setSourceUrl(sourceUrl);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return widgetItem;
} }
} }
} }
@ -1193,6 +1296,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader)); UBApplication::showMessage(tr("Unknown content type %1").arg(pContentTypeHeader));
qWarning() << "ignoring mime type" << pContentTypeHeader ; qWarning() << "ignoring mime type" << pContentTypeHeader ;
} }
return NULL;
} }
void UBBoardController::setActiveDocumentScene(int pSceneIndex) void UBBoardController::setActiveDocumentScene(int pSceneIndex)
@ -1902,7 +2007,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
} }
return 0; return w3cWidgetItem;
} }
void UBBoardController::cut() void UBBoardController::cut()
@ -1957,7 +2062,11 @@ void UBBoardController::copy()
UBItem* ubItem = dynamic_cast<UBItem*>(gi); UBItem* ubItem = dynamic_cast<UBItem*>(gi);
if (ubItem && !mActiveScene->tools().contains(gi)) if (ubItem && !mActiveScene->tools().contains(gi))
selected << ubItem->deepCopy(); {
UBItem *itemCopy = ubItem->deepCopy();
if (itemCopy)
selected << itemCopy;
}
} }
if (selected.size() > 0) if (selected.size() > 0)
@ -2014,13 +2123,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
{ {
foreach(UBItem* item, mimeData->items()) foreach(UBItem* item, mimeData->items())
{ {
QGraphicsItem* gi = dynamic_cast<QGraphicsItem*>(item->deepCopy()); duplicateItem(item);
if (gi)
{
mActiveScene->addItem(gi);
gi->setPos(gi->pos() + QPointF(50, 50));
}
} }
return; return;

@ -39,6 +39,7 @@ class UBGraphicsVideoItem;
class UBGraphicsAudioItem; class UBGraphicsAudioItem;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
class UBBoardPaletteManager; class UBBoardPaletteManager;
class UBItem;
class UBBoardController : public UBDocumentContainer class UBBoardController : public UBDocumentContainer
@ -157,6 +158,7 @@ class UBBoardController : public UBDocumentContainer
void moveSceneToIndex(int source, int target); void moveSceneToIndex(int source, int target);
void duplicateScene(int index); void duplicateScene(int index);
void duplicateItem(UBItem *item);
void deleteScene(int index); void deleteScene(int index);
bool cacheIsVisible() {return mCacheWidgetIsEnabled;} bool cacheIsVisible() {return mCacheWidgetIsEnabled;}
@ -188,7 +190,7 @@ class UBBoardController : public UBDocumentContainer
void lastScene(); void lastScene();
void groupButtonClicked(); void groupButtonClicked();
void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false); void downloadURL(const QUrl& url, const QPointF& pPos = QPointF(0.0, 0.0), const QSize& pSize = QSize(), bool isBackground = false);
void downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false); UBItem *downloadFinished(bool pSuccess, QUrl sourceUrl, QString pHeader, QByteArray pData, QPointF pPos, QSize pSize, bool isBackground = false);
void changeBackground(bool isDark, bool isCrossed); void changeBackground(bool isDark, bool isCrossed);
void setToolCursor(int tool); void setToolCursor(int tool);
void showMessage(const QString& message, bool showSpinningWheel); void showMessage(const QString& message, bool showSpinningWheel);

@ -157,18 +157,29 @@ UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItem::deepCopy() const
UBGraphicsGroupContainerItem *copy = new UBGraphicsGroupContainerItem(parentItem()); UBGraphicsGroupContainerItem *copy = new UBGraphicsGroupContainerItem(parentItem());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copyItemParameters(copy);
// copy->resize(this->size()); // copy->resize(this->size());
return copy; return copy;
} }
void UBGraphicsGroupContainerItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsGroupContainerItem *cp = dynamic_cast<UBGraphicsGroupContainerItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
}
}
void UBGraphicsGroupContainerItem::remove() void UBGraphicsGroupContainerItem::remove()
{ {
if (mDelegate) if (mDelegate)

@ -24,6 +24,8 @@ public:
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual UBGraphicsGroupContainerItem *deepCopy() const; virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove(); virtual void remove();
enum { Type = UBGraphicsItemType::groupContainerType }; enum { Type = UBGraphicsItemType::groupContainerType };

@ -406,10 +406,7 @@ bool UBGraphicsItemDelegate::isLocked()
void UBGraphicsItemDelegate::duplicate() void UBGraphicsItemDelegate::duplicate()
{ {
// TODO UB 4.x .. rewrite .. .this is absurde ... we know what we are duplicating UBApplication::boardController->duplicateItem(dynamic_cast<UBItem*>(delegated()));
UBApplication::boardController->copy();
UBApplication::boardController->paste();
} }
void UBGraphicsItemDelegate::increaseZLevelUp() void UBGraphicsItemDelegate::increaseZLevelUp()

@ -241,26 +241,34 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
UBItem* UBGraphicsMediaItem::deepCopy() const UBItem* UBGraphicsMediaItem::deepCopy() const
{ {
QUrl url = this->mediaFileUrl(); QUrl url = this->mediaFileUrl();
UBGraphicsMediaItem *copy; UBGraphicsMediaItem *copy = new UBGraphicsMediaItem(url, parentItem());
copy = new UBGraphicsMediaItem(url, parentItem()); copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copy->setPos(this->pos()); copyItemParameters(copy);
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK as long as Videos are imutable
copy->setSourceUrl(this->sourceUrl());
copy->resize(this->size());
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), copy, SLOT(activeSceneChanged()));
// TODO UB 4.7 complete all members
return copy; return copy;
} }
void UBGraphicsMediaItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsMediaItem *cp = dynamic_cast<UBGraphicsMediaItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
cp->resize(this->size());
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), cp, SLOT(activeSceneChanged()));
// TODO UB 4.7 complete all members
}
}
void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate) if (mDelegate)

@ -95,6 +95,8 @@ public:
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setSourceUrl(const QUrl &pSourceUrl) virtual void setSourceUrl(const QUrl &pSourceUrl)
{ {
UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(mAudioWidget); UBAudioPresentationWidget* pAudioWidget = dynamic_cast<UBAudioPresentationWidget*>(mAudioWidget);

@ -89,17 +89,26 @@ UBItem* UBGraphicsPDFItem::deepCopy() const
{ {
UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, parentItem()); UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, parentItem());
copy->setPos(this->pos()); copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copyItemParameters(copy);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setUuid(this->uuid()); // this is OK for now as long as PDF are imutable
copy->setSourceUrl(this->sourceUrl());
return copy; return copy;
} }
void UBGraphicsPDFItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsPDFItem *cp = dynamic_cast<UBGraphicsPDFItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setSourceUrl(this->sourceUrl());
}
}
void UBGraphicsPDFItem::setRenderingQuality(RenderingQuality pRenderingQuality) void UBGraphicsPDFItem::setRenderingQuality(RenderingQuality pRenderingQuality)
{ {

@ -41,6 +41,8 @@ class UBGraphicsPDFItem: public GraphicsPDFItem, public UBItem, public UBGraphic
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setRenderingQuality(RenderingQuality pRenderingQuality); virtual void setRenderingQuality(RenderingQuality pRenderingQuality);
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();

@ -114,22 +114,30 @@ UBItem* UBGraphicsPixmapItem::deepCopy() const
{ {
UBGraphicsPixmapItem* copy = new UBGraphicsPixmapItem(); UBGraphicsPixmapItem* copy = new UBGraphicsPixmapItem();
copy->setPixmap(this->pixmap()); copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // This is OK for now, as long as pixmaps are immutable - copyItemParameters(copy);
copy->setSourceUrl(this->sourceUrl());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
return copy; return copy;
} }
void UBGraphicsPixmapItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsPixmapItem *cp = dynamic_cast<UBGraphicsPixmapItem*>(copy);
if (cp)
{
cp->setPixmap(this->pixmap());
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
}
}
UBGraphicsScene* UBGraphicsPixmapItem::scene() UBGraphicsScene* UBGraphicsPixmapItem::scene()
{ {

@ -40,6 +40,8 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
} }
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void remove(); virtual void remove();

@ -156,28 +156,36 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
{ {
UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(pol); UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(pol);
copy->mOriginalLine = QLineF(); copyItemParameters(copy);
copy->mOriginalWidth = -1;
copy->mIsNominalLine = false;
copy->setStroke(this->stroke()); // TODO UB 4.7 ... complete all members ?
copy->setStrokesGroup(this->strokesGroup());
copy->setBrush(this->brush());
copy->setPen(this->pen());
copy->mHasAlpha = this->mHasAlpha;
return copy;
copy->setColorOnDarkBackground(this->colorOnDarkBackground()); }
copy->setColorOnLightBackground(this->colorOnLightBackground());
void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsPolygonItem *cp = dynamic_cast<UBGraphicsPolygonItem*>(copy);
if (cp)
{
cp->mOriginalLine = QLineF();
cp->mOriginalWidth = -1;
cp->mIsNominalLine = false;
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setStroke(this->stroke());
cp->setStrokesGroup(this->strokesGroup());
cp->setBrush(this->brush());
cp->setPen(this->pen());
cp->mHasAlpha = this->mHasAlpha;
// TODO UB 4.7 ... complete all members ?
return copy; cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground());
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
}
} }
void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{ {

@ -88,6 +88,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
// optimisation (eraser) // optimisation (eraser)
UBGraphicsPolygonItem* deepCopy(const QPolygonF& pol) const; UBGraphicsPolygonItem* deepCopy(const QPolygonF& pol) const;
virtual void copyItemParameters(UBItem *copy) const;
QLineF originalLine() { return mOriginalLine;} QLineF originalLine() { return mOriginalLine;}
qreal originalWidth() { return mOriginalWidth;} qreal originalWidth() { return mOriginalWidth;}

@ -1539,11 +1539,15 @@ void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
setDocumentUpdated(); setDocumentUpdated();
} }
UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos) UBGraphicsSvgItem* UBGraphicsScene::addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos, const QByteArray pData)
{ {
QString path = pSvgFileUrl.toLocalFile(); QString path = pSvgFileUrl.toLocalFile();
UBGraphicsSvgItem *svgItem = new UBGraphicsSvgItem(path); UBGraphicsSvgItem *svgItem;
if (pData.isNull())
svgItem = new UBGraphicsSvgItem(path);
else
svgItem = new UBGraphicsSvgItem(pData);
svgItem->setFlag(QGraphicsItem::ItemIsMovable, true); svgItem->setFlag(QGraphicsItem::ItemIsMovable, true);
svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true); svgItem->setFlag(QGraphicsItem::ItemIsSelectable, true);

@ -109,6 +109,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const {Q_UNUSED(copy);}
UBGraphicsScene* sceneDeepCopy() const; UBGraphicsScene* sceneDeepCopy() const;
void clearItemsAndAnnotations(); void clearItemsAndAnnotations();
@ -136,7 +138,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsMediaItem* addMedia(const QUrl& pMediaFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsMediaItem* addMedia(const QUrl& pMediaFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsMediaItem* addVideo(const QUrl& pVideoFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsMediaItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0)); UBGraphicsMediaItem* addAudio(const QUrl& pAudioFileUrl, bool shouldPlayAsap, const QPointF& pPos = QPointF(0, 0));
UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0)); UBGraphicsSvgItem* addSvg(const QUrl& pSvgFileUrl, const QPointF& pPos = QPointF(0, 0), const QByteArray pData = QByteArray());
UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0)); UBGraphicsTextItem* addText(const QString& pString, const QPointF& pTopLeft = QPointF(0, 0));
UBGraphicsTextItem* textForObjectName(const QString& pString, const QString &objectName = "UBTGZeroPageSessionTitle"); UBGraphicsTextItem* textForObjectName(const QString& pString, const QString &objectName = "UBTGZeroPageSessionTitle");

@ -63,16 +63,25 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
{ {
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
copy->setPos(this->pos()); copyItemParameters(copy);
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
return copy; return copy;
} }
void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
{
UBGraphicsStrokesGroup *cp = dynamic_cast<UBGraphicsStrokesGroup*>(copy);
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
}
}
void UBGraphicsStrokesGroup::remove() void UBGraphicsStrokesGroup::remove()
{ {
if (mDelegate) if (mDelegate)

@ -14,6 +14,7 @@ public:
UBGraphicsStrokesGroup(QGraphicsItem* parent = 0); UBGraphicsStrokesGroup(QGraphicsItem* parent = 0);
~UBGraphicsStrokesGroup(); ~UBGraphicsStrokesGroup();
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove(); virtual void remove();
virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;} virtual UBGraphicsItemDelegate* Delegate() const {return mDelegate;}
enum { Type = UBGraphicsItemType::StrokeItemType }; enum { Type = UBGraphicsItemType::StrokeItemType };

@ -135,14 +135,9 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
{ {
UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData()); UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData());
copy->setPos(this->pos()); copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true); copyItemParameters(copy);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK for now as long as SVG are imutable
copy->setSourceUrl(this->sourceUrl());
// TODO UB 4.7... complete all members ? // TODO UB 4.7... complete all members ?
@ -150,6 +145,20 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
} }
void UBGraphicsSvgItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsSvgItem *cp = dynamic_cast<UBGraphicsSvgItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
}
}
void UBGraphicsSvgItem::setRenderingQuality(RenderingQuality pRenderingQuality) void UBGraphicsSvgItem::setRenderingQuality(RenderingQuality pRenderingQuality)
{ {

@ -52,6 +52,8 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setRenderingQuality(RenderingQuality pRenderingQuality); virtual void setRenderingQuality(RenderingQuality pRenderingQuality);
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();

@ -201,28 +201,36 @@ UBItem* UBGraphicsTextItem::deepCopy() const
{ {
UBGraphicsTextItem* copy = new UBGraphicsTextItem(); UBGraphicsTextItem* copy = new UBGraphicsTextItem();
copy->setHtml(toHtml()); copyItemParameters(copy);
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setData(UBGraphicsItemData::ItemEditable, data(UBGraphicsItemData::ItemEditable).toBool());
// copy->setDefaultTextColor(this->defaultTextColor());
// copy->setFont(this->font());
// copy->setColorOnDarkBackground(this->colorOnDarkBackground());
// copy->setColorOnLightBackground(this->colorOnLightBackground());
copy->setTextWidth(this->textWidth());
copy->setTextHeight(this->textHeight());
copy->setSourceUrl(this->sourceUrl());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
return copy; return copy;
} }
void UBGraphicsTextItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsTextItem *cp = dynamic_cast<UBGraphicsTextItem*>(copy);
if (cp)
{
cp->setHtml(toHtml());
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setData(UBGraphicsItemData::ItemEditable, data(UBGraphicsItemData::ItemEditable).toBool());
// cp->setDefaultTextColor(this->defaultTextColor());
// cp->setFont(this->font());
// cp->setColorOnDarkBackground(this->colorOnDarkBackground());
// cp->setColorOnLightBackground(this->colorOnLightBackground());
cp->setTextWidth(this->textWidth());
cp->setTextHeight(this->textHeight());
cp->setSourceUrl(this->sourceUrl());
}
}
QRectF UBGraphicsTextItem::boundingRect() const QRectF UBGraphicsTextItem::boundingRect() const
{ {

@ -40,6 +40,9 @@ class UBGraphicsTextItem : public QGraphicsTextItem, public UBItem, public UBRes
} }
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual QRectF boundingRect() const; virtual QRectF boundingRect() const;

@ -330,19 +330,29 @@ UBItem* UBGraphicsAppleWidgetItem::deepCopy() const
{ {
UBGraphicsAppleWidgetItem *appleWidget = new UBGraphicsAppleWidgetItem(mWebKitWidget->widgetUrl(), parentItem()); UBGraphicsAppleWidgetItem *appleWidget = new UBGraphicsAppleWidgetItem(mWebKitWidget->widgetUrl(), parentItem());
copyItemParameters(appleWidget);
return appleWidget;
}
void UBGraphicsAppleWidgetItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsAppleWidgetItem *cp = dynamic_cast<UBGraphicsAppleWidgetItem*>(copy);
if (cp)
{
foreach(QString key, mPreferences.keys()) foreach(QString key, mPreferences.keys())
{ {
appleWidget->setPreference(key, mPreferences.value(key)); cp->setPreference(key, mPreferences.value(key));
} }
foreach(QString key, mDatastore.keys()) foreach(QString key, mDatastore.keys())
{ {
appleWidget->setDatastoreEntry(key, mDatastore.value(key)); cp->setDatastoreEntry(key, mDatastore.value(key));
} }
appleWidget->setSourceUrl(this->sourceUrl()); cp->setSourceUrl(this->sourceUrl());
}
return appleWidget;
} }
void UBGraphicsAppleWidgetItem::setUuid(const QUuid &pUuid) void UBGraphicsAppleWidgetItem::setUuid(const QUuid &pUuid)
@ -431,27 +441,35 @@ UBW3CWidget* UBGraphicsW3CWidgetItem::w3cWidget() const
UBItem* UBGraphicsW3CWidgetItem::deepCopy() const UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
{ {
UBGraphicsW3CWidgetItem *copy = new UBGraphicsW3CWidgetItem(mWebKitWidget->widgetUrl(), parentItem()); UBGraphicsW3CWidgetItem *copy = new UBGraphicsW3CWidgetItem(mWebKitWidget->widgetUrl(), parentItem());
copy->setPos(this->pos());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
copy->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copy->setSourceUrl(this->sourceUrl()); copyItemParameters(copy);
return copy;
}
void UBGraphicsW3CWidgetItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsW3CWidgetItem *cp = dynamic_cast<UBGraphicsW3CWidgetItem*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked));
cp->setSourceUrl(this->sourceUrl());
copy->resize(this->size()); cp->resize(this->size());
foreach(QString key, mPreferences.keys()) foreach(QString key, mPreferences.keys())
{ {
copy->setPreference(key, mPreferences.value(key)); cp->setPreference(key, mPreferences.value(key));
} }
foreach(QString key, mDatastore.keys()) foreach(QString key, mDatastore.keys())
{ {
copy->setDatastoreEntry(key, mDatastore.value(key)); cp->setDatastoreEntry(key, mDatastore.value(key));
}
} }
return copy;
} }

@ -130,6 +130,9 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
} }
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
}; };
@ -152,6 +155,8 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
UBW3CWidget::Metadata metadatas() const; UBW3CWidget::Metadata metadatas() const;
UBW3CWidget* w3cWidget() const; UBW3CWidget* w3cWidget() const;

@ -20,6 +20,7 @@
#include "core/UB.h" #include "core/UB.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsItem;
class UBItem class UBItem
{ {
@ -58,6 +59,8 @@ class UBItem
virtual UBItem* deepCopy() const = 0; virtual UBItem* deepCopy() const = 0;
virtual void copyItemParameters(UBItem *copy) const = 0;
virtual UBGraphicsScene* scene() // TODO UB 4.x should be pure virtual ... virtual UBGraphicsScene* scene() // TODO UB 4.x should be pure virtual ...
{ {
return 0; return 0;

@ -45,15 +45,24 @@ UBItem* UBGraphicsCache::deepCopy() const
{ {
UBGraphicsCache* copy = new UBGraphicsCache(); UBGraphicsCache* copy = new UBGraphicsCache();
copy->setPos(this->pos()); copyItemParameters(copy);
copy->setRect(this->rect());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
return copy; return copy;
} }
void UBGraphicsCache::copyItemParameters(UBItem *copy) const
{
UBGraphicsCache *cp = dynamic_cast<UBGraphicsCache*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
}
}
QColor UBGraphicsCache::maskColor() QColor UBGraphicsCache::maskColor()
{ {
return mMaskColor; return mMaskColor;

@ -39,6 +39,8 @@ public:
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
QColor maskColor(); QColor maskColor();
void setMaskColor(QColor color); void setMaskColor(QColor color);
eMaskShape maskshape(); eMaskShape maskshape();

@ -86,15 +86,24 @@ UBItem* UBGraphicsCompass::deepCopy() const
{ {
UBGraphicsCompass* copy = new UBGraphicsCompass(); UBGraphicsCompass* copy = new UBGraphicsCompass();
copy->setPos(this->pos()); copyItemParameters(copy);
copy->setRect(this->rect());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
return copy; return copy;
} }
void UBGraphicsCompass::copyItemParameters(UBItem *copy) const
{
UBGraphicsCompass *cp = dynamic_cast<UBGraphicsCompass*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
}
}
void UBGraphicsCompass::paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget) void UBGraphicsCompass::paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget)
{ {
Q_UNUSED(styleOption); Q_UNUSED(styleOption);

@ -41,6 +41,8 @@ class UBGraphicsCompass: public QObject, public QGraphicsRectItem, public UBItem
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
signals: signals:
void hidden(); void hidden();

@ -133,20 +133,28 @@ UBItem* UBGraphicsCurtainItem::deepCopy() const
{ {
UBGraphicsCurtainItem* copy = new UBGraphicsCurtainItem(); UBGraphicsCurtainItem* copy = new UBGraphicsCurtainItem();
copy->setRect(this->rect()); copyItemParameters(copy);
copy->setPos(this->pos());
copy->setBrush(this->brush());
copy->setPen(this->pen());
copy->setTransform(this->transform());
copy->setFlag(QGraphicsItem::ItemIsMovable, true);
copy->setFlag(QGraphicsItem::ItemIsSelectable, true);
copy->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
return copy; return copy;
} }
void UBGraphicsCurtainItem::copyItemParameters(UBItem *copy) const
{
UBGraphicsCurtainItem *cp = dynamic_cast<UBGraphicsCurtainItem*>(copy);
if (cp)
{
cp->setRect(this->rect());
cp->setPos(this->pos());
cp->setBrush(this->brush());
cp->setPen(this->pen());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
}
}
QColor UBGraphicsCurtainItem::drawColor() const QColor UBGraphicsCurtainItem::drawColor() const
{ {

@ -42,6 +42,7 @@ class UBGraphicsCurtainItem : public QObject, public QGraphicsRectItem, public U
} }
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void remove(); virtual void remove();

@ -579,20 +579,27 @@ UBItem* UBGraphicsProtractor::deepCopy() const
{ {
UBGraphicsProtractor* copy = new UBGraphicsProtractor(); UBGraphicsProtractor* copy = new UBGraphicsProtractor();
copy->setPos(this->pos()); copyItemParameters(copy);
copy->setRect(this->rect());
copy->setTransform(this->transform());
copy->mCurrentAngle = this->mCurrentAngle;
copy->mSpan = this->mSpan;
copy->mStartAngle = this->mStartAngle;
copy->mScaleFactor = this->mScaleFactor;
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
return copy; return copy;
} }
void UBGraphicsProtractor::copyItemParameters(UBItem *copy) const
{
UBGraphicsProtractor *cp = dynamic_cast<UBGraphicsProtractor*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
cp->mCurrentAngle = this->mCurrentAngle;
cp->mSpan = this->mSpan;
cp->mStartAngle = this->mStartAngle;
cp->mScaleFactor = this->mScaleFactor;
}
}
void UBGraphicsProtractor::rotateAroundCenter(qreal angle) void UBGraphicsProtractor::rotateAroundCenter(qreal angle)
{ {

@ -40,6 +40,7 @@ class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipse
void setMarkerAngle (qreal angle) { mCurrentAngle = angle; } void setMarkerAngle (qreal angle) { mCurrentAngle = angle; }
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
enum { Type = UBGraphicsItemType::ProtractorItemType }; enum { Type = UBGraphicsItemType::ProtractorItemType };

@ -75,15 +75,24 @@ UBItem* UBGraphicsRuler::deepCopy() const
{ {
UBGraphicsRuler* copy = new UBGraphicsRuler(); UBGraphicsRuler* copy = new UBGraphicsRuler();
copy->setPos(this->pos()); copyItemParameters(copy);
copy->setRect(this->rect());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
return copy; return copy;
} }
void UBGraphicsRuler::copyItemParameters(UBItem *copy) const
{
UBGraphicsRuler *cp = dynamic_cast<UBGraphicsRuler*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setRect(this->rect());
cp->setTransform(this->transform());
}
}
void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget) void UBGraphicsRuler::paint(QPainter *painter, const QStyleOptionGraphicsItem *styleOption, QWidget *widget)
{ {
Q_UNUSED(styleOption); Q_UNUSED(styleOption);

@ -41,6 +41,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
} }
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void StartLine(const QPointF& position, qreal width); virtual void StartLine(const QPointF& position, qreal width);
virtual void DrawLine(const QPointF& position, qreal width); virtual void DrawLine(const QPointF& position, qreal width);

@ -94,9 +94,7 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const
{ {
UBGraphicsTriangle* copy = new UBGraphicsTriangle(); UBGraphicsTriangle* copy = new UBGraphicsTriangle();
copy->setPos(this->pos()); copyItemParameters(copy);
copy->setPolygon(this->polygon());
copy->setTransform(this->transform());
// TODO UB 4.7 ... complete all members ? // TODO UB 4.7 ... complete all members ?
@ -104,6 +102,17 @@ UBItem* UBGraphicsTriangle::deepCopy(void) const
} }
void UBGraphicsTriangle::copyItemParameters(UBItem *copy) const
{
UBGraphicsTriangle* cp = dynamic_cast<UBGraphicsTriangle*>(copy);
if (cp)
{
cp->setPos(this->pos());
cp->setPolygon(this->polygon());
cp->setTransform(this->transform());
}
}
void UBGraphicsTriangle::setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation) void UBGraphicsTriangle::setRect(qreal x, qreal y, qreal w, qreal h, UBGraphicsTriangleOrientation orientation)
{ {
QPolygonF polygon; QPolygonF polygon;

@ -45,6 +45,7 @@ class UBGraphicsTriangle : public UBAbstractDrawRuler, public QGraphicsPolygonIt
virtual UBItem* deepCopy(void) const; virtual UBItem* deepCopy(void) const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void StartLine(const QPointF& scenePos, qreal width); virtual void StartLine(const QPointF& scenePos, qreal width);
virtual void DrawLine(const QPointF& position, qreal width); virtual void DrawLine(const QPointF& position, qreal width);

Loading…
Cancel
Save