Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
commit 394c3d5db6
  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/UBPageSizeUndoCommand.h"
#include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBItem.h"
#include "tools/UBToolsManager.h"
@ -529,6 +530,92 @@ void UBBoardController::duplicateScene()
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)
{
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;
@ -869,7 +956,7 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
if (!pSuccess)
{
UBApplication::showMessage(tr("Downloading content %1 failed").arg(sourceUrl.toString()));
return;
return NULL;
}
if (!sourceUrl.toString().startsWith("file://") && !sourceUrl.toString().startsWith("uniboardTool://"))
@ -897,12 +984,14 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
pixItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
return pixItem;
}
else if (UBMimeType::VectorImage == itemMimeType)
{
qDebug() << "accepting mime type" << mimeType << "as vecto image";
UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos);
UBGraphicsSvgItem* svgItem = mActiveScene->addSvg(sourceUrl, pPos, pData);
svgItem->setSourceUrl(sourceUrl);
if (isBackground)
@ -915,6 +1004,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
svgItem->setSelected(true);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
return svgItem;
}
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);
}
return appleWidgetItem;
}
else if (UBMimeType::W3CWidget == itemMimeType)
{
@ -960,6 +1053,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
{
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
return w3cWidgetItem;
}
else if (UBMimeType::Video == itemMimeType)
{
@ -989,6 +1084,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
}
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return mediaVideoItem;
}
else if (UBMimeType::Audio == itemMimeType)
{
@ -1018,6 +1115,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
}
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return audioMediaItem;
}
else if (UBMimeType::Flash == itemMimeType)
@ -1061,6 +1160,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
widgetItem->setSourceUrl(sourceUrl);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
return widgetItem;
}
if (eduMediaFile)
@ -1182,6 +1283,8 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
widgetItem->setSourceUrl(sourceUrl);
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));
qWarning() << "ignoring mime type" << pContentTypeHeader ;
}
return NULL;
}
void UBBoardController::setActiveDocumentScene(int pSceneIndex)
@ -1902,7 +2007,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP
}
return 0;
return w3cWidgetItem;
}
void UBBoardController::cut()
@ -1957,7 +2062,11 @@ void UBBoardController::copy()
UBItem* ubItem = dynamic_cast<UBItem*>(gi);
if (ubItem && !mActiveScene->tools().contains(gi))
selected << ubItem->deepCopy();
{
UBItem *itemCopy = ubItem->deepCopy();
if (itemCopy)
selected << itemCopy;
}
}
if (selected.size() > 0)
@ -2014,13 +2123,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
{
foreach(UBItem* item, mimeData->items())
{
QGraphicsItem* gi = dynamic_cast<QGraphicsItem*>(item->deepCopy());
if (gi)
{
mActiveScene->addItem(gi);
gi->setPos(gi->pos() + QPointF(50, 50));
}
duplicateItem(item);
}
return;

@ -39,6 +39,7 @@ class UBGraphicsVideoItem;
class UBGraphicsAudioItem;
class UBGraphicsWidgetItem;
class UBBoardPaletteManager;
class UBItem;
class UBBoardController : public UBDocumentContainer
@ -157,6 +158,7 @@ class UBBoardController : public UBDocumentContainer
void moveSceneToIndex(int source, int target);
void duplicateScene(int index);
void duplicateItem(UBItem *item);
void deleteScene(int index);
bool cacheIsVisible() {return mCacheWidgetIsEnabled;}
@ -188,7 +190,7 @@ class UBBoardController : public UBDocumentContainer
void lastScene();
void groupButtonClicked();
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 setToolCursor(int tool);
void showMessage(const QString& message, bool showSpinningWheel);

@ -157,18 +157,29 @@ UBGraphicsGroupContainerItem *UBGraphicsGroupContainerItem::deepCopy() const
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
copyItemParameters(copy);
// copy->resize(this->size());
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()
{
if (mDelegate)

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

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

@ -241,26 +241,34 @@ void UBGraphicsMediaItem::showOnDisplayChanged(bool shown)
UBItem* UBGraphicsMediaItem::deepCopy() const
{
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());
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
copyItemParameters(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)
{
if (mDelegate)

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

@ -89,17 +89,26 @@ UBItem* UBGraphicsPDFItem::deepCopy() const
{
UBGraphicsPDFItem *copy = new UBGraphicsPDFItem(mRenderer, mPageNumber, 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->setUuid(this->uuid()); // this is OK for now as long as PDF are imutable
copy->setSourceUrl(this->sourceUrl());
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copyItemParameters(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)
{

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

@ -114,22 +114,30 @@ UBItem* UBGraphicsPixmapItem::deepCopy() const
{
UBGraphicsPixmapItem* copy = new UBGraphicsPixmapItem();
copy->setPixmap(this->pixmap());
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 pixmaps are immutable -
copy->setSourceUrl(this->sourceUrl());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
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()
{

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

@ -156,28 +156,36 @@ UBGraphicsPolygonItem* UBGraphicsPolygonItem::deepCopy(const QPolygonF& pol) con
{
UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(pol);
copy->mOriginalLine = QLineF();
copy->mOriginalWidth = -1;
copy->mIsNominalLine = false;
copyItemParameters(copy);
copy->setStroke(this->stroke());
copy->setStrokesGroup(this->strokesGroup());
copy->setBrush(this->brush());
copy->setPen(this->pen());
copy->mHasAlpha = this->mHasAlpha;
// TODO UB 4.7 ... complete all members ?
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)
{

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

@ -1539,11 +1539,15 @@ void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
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();
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::ItemIsSelectable, true);

@ -109,6 +109,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const {Q_UNUSED(copy);}
UBGraphicsScene* sceneDeepCopy() const;
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* 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));
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* textForObjectName(const QString& pString, const QString &objectName = "UBTGZeroPageSessionTitle");

@ -63,16 +63,25 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
{
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
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));
copyItemParameters(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()
{
if (mDelegate)

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

@ -135,14 +135,9 @@ UBItem* UBGraphicsSvgItem::deepCopy() const
{
UBGraphicsSvgItem* copy = new UBGraphicsSvgItem(this->fileData());
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 SVG are imutable
copy->setSourceUrl(this->sourceUrl());
copy->setUuid(this->uuid()); // this is OK for now as long as Widgets are imutable
copyItemParameters(copy);
// 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)
{

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

@ -201,28 +201,36 @@ UBItem* UBGraphicsTextItem::deepCopy() const
{
UBGraphicsTextItem* copy = new UBGraphicsTextItem();
copy->setHtml(toHtml());
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());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
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
{

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

@ -330,19 +330,29 @@ UBItem* UBGraphicsAppleWidgetItem::deepCopy() const
{
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())
{
appleWidget->setPreference(key, mPreferences.value(key));
cp->setPreference(key, mPreferences.value(key));
}
foreach(QString key, mDatastore.keys())
{
appleWidget->setDatastoreEntry(key, mDatastore.value(key));
cp->setDatastoreEntry(key, mDatastore.value(key));
}
appleWidget->setSourceUrl(this->sourceUrl());
return appleWidget;
cp->setSourceUrl(this->sourceUrl());
}
}
void UBGraphicsAppleWidgetItem::setUuid(const QUuid &pUuid)
@ -431,27 +441,35 @@ UBW3CWidget* UBGraphicsW3CWidgetItem::w3cWidget() const
UBItem* UBGraphicsW3CWidgetItem::deepCopy() const
{
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->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())
{
copy->setPreference(key, mPreferences.value(key));
cp->setPreference(key, mPreferences.value(key));
}
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 void copyItemParameters(UBItem *copy) const;
virtual void setUuid(const QUuid &pUuid);
};
@ -152,6 +155,8 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
UBW3CWidget::Metadata metadatas() const;
UBW3CWidget* w3cWidget() const;

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

@ -45,15 +45,24 @@ UBItem* UBGraphicsCache::deepCopy() const
{
UBGraphicsCache* copy = new UBGraphicsCache();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
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()
{
return mMaskColor;

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

@ -86,15 +86,24 @@ UBItem* UBGraphicsCompass::deepCopy() const
{
UBGraphicsCompass* copy = new UBGraphicsCompass();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
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)
{
Q_UNUSED(styleOption);

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

@ -133,20 +133,28 @@ UBItem* UBGraphicsCurtainItem::deepCopy() const
{
UBGraphicsCurtainItem* copy = new UBGraphicsCurtainItem();
copy->setRect(this->rect());
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));
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
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
{

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

@ -579,20 +579,27 @@ UBItem* UBGraphicsProtractor::deepCopy() const
{
UBGraphicsProtractor* copy = new UBGraphicsProtractor();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copy->mCurrentAngle = this->mCurrentAngle;
copy->mSpan = this->mSpan;
copy->mStartAngle = this->mStartAngle;
copy->mScaleFactor = this->mScaleFactor;
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
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)
{

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

@ -75,15 +75,24 @@ UBItem* UBGraphicsRuler::deepCopy() const
{
UBGraphicsRuler* copy = new UBGraphicsRuler();
copy->setPos(this->pos());
copy->setRect(this->rect());
copy->setTransform(this->transform());
copyItemParameters(copy);
// TODO UB 4.7 ... complete all members ?
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)
{
Q_UNUSED(styleOption);

@ -41,6 +41,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
}
virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
virtual void StartLine(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();
copy->setPos(this->pos());
copy->setPolygon(this->polygon());
copy->setTransform(this->transform());
copyItemParameters(copy);
// 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)
{
QPolygonF polygon;

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

Loading…
Cancel
Save