diff --git a/src/adaptors/UBImportAdaptor.cpp b/src/adaptors/UBImportAdaptor.cpp index 0a842f3e..790c809a 100644 --- a/src/adaptors/UBImportAdaptor.cpp +++ b/src/adaptors/UBImportAdaptor.cpp @@ -53,27 +53,3 @@ UBDocumentBasedImportAdaptor::UBDocumentBasedImportAdaptor(QObject *parent) { // NOOP } - - -/* -UBDocumentProxy* UBImportAdaptor::importFile(const QFile& pFile, const QString& pGroup) -{ - QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); - - UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); - - bool result = addFileToDocument(newDocument, pFile); - - if (result) - { - UBPersistenceManager::persistenceManager()->persistDocumentMetadata(newDocument); - } - else - { - UBPersistenceManager::persistenceManager()->deleteDocument(newDocument); - newDocument = 0; - } - - return newDocument; -} -*/ \ No newline at end of file diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 2c34f2cb..cf84fdd1 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -51,7 +51,6 @@ #include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsItemUndoCommand.h" -#include "domain/UBGraphicsProxyWidget.h" #include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsMediaItem.h" @@ -1319,6 +1318,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl Q_UNUSED(internalData) QString widgetUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapper(sUrl, mimeType, size); + UBFileSystemUtils::deleteFile(sourceUrl.toLocalFile()); emit npapiWidgetCreated(widgetUrl); if (widgetUrl.length() > 0) @@ -1326,6 +1326,13 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl UBGraphicsWidgetItem *widgetItem = mActiveScene->addW3CWidget(QUrl::fromLocalFile(widgetUrl), pPos); widgetItem->setUuid(QUuid::createUuid()); widgetItem->setSourceUrl(QUrl::fromLocalFile(widgetUrl)); + qDebug() << widgetItem->getOwnFolder(); + qDebug() << widgetItem->getSnapshotPath(); + QString ownFolder = selectedDocument()->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + widgetItem->uuid().toString() + ".wgt"; + widgetItem->setOwnFolder(ownFolder); + QString adaptedUUid = widgetItem->uuid().toString().replace("{","").replace("}",""); + ownFolder = ownFolder.replace(widgetItem->uuid().toString() + ".wgt", adaptedUUid + ".png"); + widgetItem->setSnapshotPath(ownFolder); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); @@ -1551,11 +1558,11 @@ void UBBoardController::moveSceneToIndex(int source, int target) } } -void UBBoardController::fitUniqIems(const QUndoCommand *parent, QSet &itms) +void UBBoardController::findUniquesItems(const QUndoCommand *parent, QSet &itms) { if (parent->childCount()) { for (int i = 0; i < parent->childCount(); i++) { - fitUniqIems(parent->child(i), itms); + findUniquesItems(parent->child(i), itms); } } @@ -1564,11 +1571,11 @@ void UBBoardController::fitUniqIems(const QUndoCommand *parent, QSet(parent); - if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM) + const UBUndoCommand *undoCmd = static_cast(parent); + if(undoCmd->getType() != UBUndoType::undotype_GRAPHICITEM) return; - const UBGraphicsItemUndoCommand *cmd = static_cast(parent); + const UBGraphicsItemUndoCommand *cmd = dynamic_cast(parent); // go through all added and removed objects, for create list of unique objects // grouped items will be deleted by groups, so we don't need do delete that items. @@ -1594,7 +1601,7 @@ void UBBoardController::ClearUndoStack() QSet uniqueItems; // go through all stack command for (int i = 0; i < UBApplication::undoStack->count(); i++) { - fitUniqIems(UBApplication::undoStack->command(i), uniqueItems); + findUniquesItems(UBApplication::undoStack->command(i), uniqueItems); } // go through all unique items, and check, if they are on scene, or not. @@ -2124,7 +2131,7 @@ UBGraphicsWidgetItem *UBBoardController::addW3cWidget(const QUrl &pUrl, const QP QUuid uuid = QUuid::createUuid(); QString destPath; - if (!UBPersistenceManager::persistenceManager()->addGraphicsWidgteToDocument(selectedDocument(), pUrl.toLocalFile(), uuid, destPath)) + if (!UBPersistenceManager::persistenceManager()->addGraphicsWidgetToDocument(selectedDocument(), pUrl.toLocalFile(), uuid, destPath)) return NULL; QUrl newUrl = QUrl::fromLocalFile(destPath); diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index d6e56421..37b8a75d 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -160,7 +160,7 @@ class UBBoardController : public UBDocumentContainer void notifyPageChanged(); void displayMetaData(QMap metadatas); - void fitUniqIems(const QUndoCommand *parent, QSet &itms); + void findUniquesItems(const QUndoCommand *parent, QSet &itms); void ClearUndoStack(); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false); diff --git a/src/core/UB.h b/src/core/UB.h index 493590c8..ab42fb7f 100644 --- a/src/core/UB.h +++ b/src/core/UB.h @@ -195,4 +195,13 @@ struct DocumentSizeRatio }; }; + +struct UBUndoType +{ + enum Enum + { + undotype_UNKNOWN = 0, undotype_DOCUMENT, undotype_GRAPHICITEMTRANSFORM, undotype_GRAPHICITEM, undotype_GRAPHICTEXTITEM, undotype_PAGESIZE, undotype_GRAPHICSGROUPITEM + }; +}; + #endif /* UB_H_ */ diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index a9ec444e..ab267208 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -40,6 +40,11 @@ #include "adaptors/UBThumbnailAdaptor.h" #include "adaptors/UBMetadataDcSubsetAdaptor.h" +#include "domain/UBGraphicsMediaItem.h" +#include "domain/UBGraphicsWidgetItem.h" +#include "domain/UBGraphicsPixmapItem.h" +#include "domain/UBGraphicsSvgItem.h" + #include "board/UBBoardController.h" #include "board/UBBoardPaletteManager.h" @@ -255,7 +260,7 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName, } doc->setMetaData(UBSettings::documentVersion, UBSettings::currentFileVersion); - QString currentDate = UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()); + QString currentDate = UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()); doc->setMetaData(UBSettings::documentUpdatedAt,currentDate); doc->setMetaData(UBSettings::documentDate,currentDate); @@ -396,12 +401,14 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL foreach(int index, compactedIndexes) { + // trig the reload of the thumbnails emit documentSceneWillBeDeleted(proxy, index); } QString sourceGroupName = proxy->metaData(UBSettings::documentGroupName).toString(); QString sourceName = proxy->metaData(UBSettings::documentName).toString(); UBDocumentProxy *trashDocProxy = createDocument(UBSettings::trashedDocumentGroupNamePrefix + sourceGroupName, sourceName, false); + generatePathIfNeeded(trashDocProxy); foreach(int index, compactedIndexes) { @@ -418,7 +425,7 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL QDir d = fi.dir(); d.mkpath(d.absolutePath()); - QFile::copy(source, target); + Q_ASSERT(QFile::rename(source, target)); } insertDocumentSceneAt(trashDocProxy, scene, trashDocProxy->pageCount()); @@ -467,6 +474,8 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL } + + void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int index) { checkIfDocumentRepositoryExists(); @@ -483,6 +492,66 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in copyPage(proxy, index , index + 1); + + //TODO: write a proper way to handle object on disk + UBGraphicsScene *scene = loadDocumentScene(proxy, index + 1); + + foreach(QGraphicsItem* item, scene->items()) + { + UBGraphicsMediaItem *mediaItem = qgraphicsitem_cast (item); + + if (mediaItem){ + QString source = mediaItem->mediaFileUrl().toLocalFile(); + QString destination = source; + QUuid newUuid = QUuid::createUuid(); + QString fileName = QFileInfo(source).completeBaseName(); + destination = destination.replace(fileName,newUuid.toString()); + Q_ASSERT(QFile::copy(source,destination)); + mediaItem->mediaFileUrl(QUrl::fromLocalFile(destination)); + continue; + } + + UBGraphicsWidgetItem* widget = qgraphicsitem_cast(item); + if(widget){ + QUuid newUUid = QUuid::createUuid(); + QString newUUidString = newUUid.toString().remove("{").remove("}"); + QString actualUuidString = widget->uuid().toString().remove("{").remove("}"); + + QString widgetSourcePath = proxy->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/{" + actualUuidString + "}.wgt"; + QString screenshotSourcePath = proxy->persistencePath() + "/" + UBPersistenceManager::widgetDirectory + "/" + actualUuidString + ".png"; + + QString widgetDestinationPath = widgetSourcePath; + widgetDestinationPath = widgetDestinationPath.replace(actualUuidString,newUUidString); + QString screenshotDestinationPath = screenshotSourcePath; + screenshotDestinationPath = screenshotDestinationPath.replace(actualUuidString,newUUidString); + + Q_ASSERT(UBFileSystemUtils::copyDir(widgetSourcePath,widgetDestinationPath)); + Q_ASSERT(QFile::copy(screenshotSourcePath,screenshotDestinationPath)); + + widget->setUuid(newUUid); + + widget->widgetUrl(QUrl::fromLocalFile(widgetDestinationPath)); + + continue; + } + + UBGraphicsPixmapItem* pixmapItem = qgraphicsitem_cast(item); + if(pixmapItem){ + pixmapItem->setUuid(QUuid::createUuid()); + continue; + } + + UBGraphicsSvgItem* svgItem = qgraphicsitem_cast(item); + if(svgItem){ + svgItem->setUuid(QUuid::createUuid()); + continue; + } + + } + scene->setModified(true); + + persistDocumentScene(proxy,scene, index + 1); + proxy->incPageCount(); emit documentSceneCreated(proxy, index + 1); @@ -859,7 +928,7 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy, } } -bool UBPersistenceManager::addGraphicsWidgteToDocument(UBDocumentProxy *pDocumentProxy, +bool UBPersistenceManager::addGraphicsWidgetToDocument(UBDocumentProxy *pDocumentProxy, QString path, QUuid objectUuid, QString& destinationPath) diff --git a/src/core/UBPersistenceManager.h b/src/core/UBPersistenceManager.h index 77708cee..6710c29e 100644 --- a/src/core/UBPersistenceManager.h +++ b/src/core/UBPersistenceManager.h @@ -103,7 +103,7 @@ class UBPersistenceManager : public QObject virtual bool isEmpty(UBDocumentProxy* pDocumentProxy); virtual void purgeEmptyDocuments(); - bool addGraphicsWidgteToDocument(UBDocumentProxy *mDocumentProxy, QString path, QUuid objectUuid, QString& destinationPath); + bool addGraphicsWidgetToDocument(UBDocumentProxy *mDocumentProxy, QString path, QUuid objectUuid, QString& destinationPath); bool addFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, const QString& subdir, QUuid objectUuid, QString& destinationPath, QByteArray* data = NULL); signals: diff --git a/src/domain/UBGraphicsItemGroupUndoCommand.cpp b/src/domain/UBGraphicsItemGroupUndoCommand.cpp index 25a3ebed..ea1df298 100644 --- a/src/domain/UBGraphicsItemGroupUndoCommand.cpp +++ b/src/domain/UBGraphicsItemGroupUndoCommand.cpp @@ -28,9 +28,10 @@ #include "core/memcheck.h" -UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) : - mScene (pScene), mGroup(pGroupCreated), mFirstRedo(true) - +UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) : UBUndoCommand() + , mScene (pScene) + , mGroup(pGroupCreated) + , mFirstRedo(true) { if (pGroupCreated->childItems().count()) { foreach (QGraphicsItem *item, pGroupCreated->childItems()) { diff --git a/src/domain/UBGraphicsItemGroupUndoCommand.h b/src/domain/UBGraphicsItemGroupUndoCommand.h index 981ebb33..c280af0e 100644 --- a/src/domain/UBGraphicsItemGroupUndoCommand.h +++ b/src/domain/UBGraphicsItemGroupUndoCommand.h @@ -25,18 +25,18 @@ #define UBGRAPHICSITEMGROUPUNDOCOMMAND_H #include -#include "UBAbstractUndoCommand.h" +#include "UBUndoCommand.h" class UBGraphicsScene; class UBGraphicsGroupContainerItem; -class UBGraphicsItemGroupUndoCommand : public UBAbstractUndoCommand +class UBGraphicsItemGroupUndoCommand : public UBUndoCommand { public: UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated); virtual ~UBGraphicsItemGroupUndoCommand(); - virtual UndoType getType() { return undotype_GRAPHICSGROUPITEM; } + virtual int getType() const { return UBUndoType::undotype_GRAPHICSGROUPITEM; } protected: virtual void undo(); diff --git a/src/domain/UBGraphicsItemTransformUndoCommand.cpp b/src/domain/UBGraphicsItemTransformUndoCommand.cpp index 316eb703..5ea77630 100644 --- a/src/domain/UBGraphicsItemTransformUndoCommand.cpp +++ b/src/domain/UBGraphicsItemTransformUndoCommand.cpp @@ -29,7 +29,7 @@ UBGraphicsItemTransformUndoCommand::UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem, const QPointF& prevPos, const QTransform& prevTransform, const qreal& prevZValue, - const QSizeF& prevSize) + const QSizeF& prevSize):UBUndoCommand() { mItem = pItem; mPreviousTransform = prevTransform; diff --git a/src/domain/UBGraphicsItemTransformUndoCommand.h b/src/domain/UBGraphicsItemTransformUndoCommand.h index aa586ec2..07e0aede 100644 --- a/src/domain/UBGraphicsItemTransformUndoCommand.h +++ b/src/domain/UBGraphicsItemTransformUndoCommand.h @@ -27,10 +27,10 @@ #include #include "UBResizableGraphicsItem.h" -#include "UBAbstractUndoCommand.h" +#include "UBUndoCommand.h" -class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand +class UBGraphicsItemTransformUndoCommand : public UBUndoCommand { public: UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem, @@ -40,7 +40,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand const QSizeF& prevSize = QSizeF()); virtual ~UBGraphicsItemTransformUndoCommand(); - virtual UndoType getType() { return undotype_GRAPHICITEMTRANSFORM; } + virtual int getType() const { return UBUndoType::undotype_GRAPHICITEMTRANSFORM; } protected: virtual void undo(); diff --git a/src/domain/UBGraphicsItemUndoCommand.cpp b/src/domain/UBGraphicsItemUndoCommand.cpp index 1923d7d5..3d134bce 100644 --- a/src/domain/UBGraphicsItemUndoCommand.cpp +++ b/src/domain/UBGraphicsItemUndoCommand.cpp @@ -35,9 +35,8 @@ #include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsPolygonItem.h" -UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet& pRemovedItems, - const QSet& pAddedItems, const GroupDataTable &groupsMap) - : mScene(pScene) +UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet& pRemovedItems, const QSet& pAddedItems, const GroupDataTable &groupsMap): UBUndoCommand() + , mScene(pScene) , mRemovedItems(pRemovedItems - pAddedItems) , mAddedItems(pAddedItems - pRemovedItems) , mExcludedFromGroup(groupsMap) @@ -57,9 +56,8 @@ UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, co } } -UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, - QGraphicsItem* pAddedItem) : - mScene(pScene) +UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, QGraphicsItem* pAddedItem) : UBUndoCommand() + , mScene(pScene) { if (pRemovedItem) diff --git a/src/domain/UBGraphicsItemUndoCommand.h b/src/domain/UBGraphicsItemUndoCommand.h index 8e88a24f..5b6f881b 100644 --- a/src/domain/UBGraphicsItemUndoCommand.h +++ b/src/domain/UBGraphicsItemUndoCommand.h @@ -25,14 +25,14 @@ #define UBGRAPHICSITEMUNDOCOMMAND_H_ #include -#include "UBAbstractUndoCommand.h" +#include "UBUndoCommand.h" #include "UBGraphicsGroupContainerItem.h" class UBGraphicsScene; -class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand +class UBGraphicsItemUndoCommand : public UBUndoCommand { public: typedef QMultiMap GroupDataTable; @@ -48,7 +48,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand QSet GetAddedList() const { return mAddedItems; } QSet GetRemovedList() const { return mRemovedItems; } - virtual UndoType getType() { return undotype_GRAPHICITEM; } + virtual int getType() const { return UBUndoType::undotype_GRAPHICITEM; } protected: virtual void undo(); diff --git a/src/domain/UBGraphicsMediaItem.h b/src/domain/UBGraphicsMediaItem.h index f69516fe..2ab8b9c7 100644 --- a/src/domain/UBGraphicsMediaItem.h +++ b/src/domain/UBGraphicsMediaItem.h @@ -57,6 +57,8 @@ public: return mMediaFileUrl; } + virtual void mediaFileUrl(QUrl url){mMediaFileUrl=url;} + Phonon::MediaObject* mediaObject() const { return mMediaObject; diff --git a/src/domain/UBGraphicsPixmapItem.cpp b/src/domain/UBGraphicsPixmapItem.cpp index adf96f0b..9bffb41c 100644 --- a/src/domain/UBGraphicsPixmapItem.cpp +++ b/src/domain/UBGraphicsPixmapItem.cpp @@ -31,6 +31,13 @@ #include "UBGraphicsItemDelegate.h" +#include "frameworks/UBFileSystemUtils.h" + +#include "core/UBApplication.h" +#include "core/UBPersistenceManager.h" + +#include "board/UBBoardController.h" + #include "core/memcheck.h" UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent) @@ -164,3 +171,11 @@ qreal UBGraphicsPixmapItem::opacity() const { return QGraphicsPixmapItem::opacity(); } + + +void UBGraphicsPixmapItem::clearSource() +{ + QString fileName = UBPersistenceManager::imageDirectory + "/" + uuid().toString() + ".png"; + QString diskPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + fileName; + UBFileSystemUtils::deleteFile(diskPath); +} diff --git a/src/domain/UBGraphicsPixmapItem.h b/src/domain/UBGraphicsPixmapItem.h index 3ef6b846..e00efc1a 100644 --- a/src/domain/UBGraphicsPixmapItem.h +++ b/src/domain/UBGraphicsPixmapItem.h @@ -57,7 +57,7 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public void setOpacity(qreal op); qreal opacity() const; - virtual void clearSource(){;} + virtual void clearSource(); virtual void setUuid(const QUuid &pUuid); diff --git a/src/domain/UBGraphicsProxyWidget.cpp b/src/domain/UBGraphicsProxyWidget.cpp index 24f3b6c7..3740b5cc 100644 --- a/src/domain/UBGraphicsProxyWidget.cpp +++ b/src/domain/UBGraphicsProxyWidget.cpp @@ -30,6 +30,13 @@ #include "UBGraphicsDelegateFrame.h" +#include "core/UBApplication.h" +#include "core/UBPersistenceManager.h" + +#include "board/UBBoardController.h" + +#include "frameworks/UBFileSystemUtils.h" + #include "core/memcheck.h" UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent) @@ -198,5 +205,3 @@ UBGraphicsScene* UBGraphicsProxyWidget::scene() { return static_cast(QGraphicsItem::scene()); } - - diff --git a/src/domain/UBGraphicsProxyWidget.h b/src/domain/UBGraphicsProxyWidget.h index 61d75538..d9686b20 100644 --- a/src/domain/UBGraphicsProxyWidget.h +++ b/src/domain/UBGraphicsProxyWidget.h @@ -44,7 +44,6 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public virtual UBGraphicsScene* scene(); - virtual void clearSource(){;} virtual void setUuid(const QUuid &pUuid); protected: diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index f3ebd071..dc008a6b 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -2089,11 +2089,39 @@ QList UBGraphicsScene::relativeDependencies() const while (itItems.hasNext()) { - UBGraphicsMediaItem *videoItem = qgraphicsitem_cast (itItems.next()); + QGraphicsItem* item = itItems.next(); + UBGraphicsMediaItem *mediaItem = qgraphicsitem_cast (item); - if (videoItem && videoItem->mediaFileUrl().isRelative()) - { - relativePathes << videoItem->mediaFileUrl(); + if (mediaItem){ + QString completeFileName = QFileInfo(mediaItem->mediaFileUrl().toLocalFile()).fileName(); + QString path; + if(mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video) + path = UBPersistenceManager::videoDirectory + "/"; + else + path = UBPersistenceManager::audioDirectory + "/"; + relativePathes << QUrl(path + completeFileName); + continue; + } + + UBGraphicsWidgetItem* widget = qgraphicsitem_cast(item); + if(widget){ + QString widgetPath = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString() + ".wgt"; + QString screenshotPath = UBPersistenceManager::widgetDirectory + "/" + widget->uuid().toString().remove("{").remove("}") + ".png"; + relativePathes << QUrl(widgetPath); + relativePathes << QUrl(screenshotPath); + continue; + } + + UBGraphicsPixmapItem* pixmapItem = qgraphicsitem_cast(item); + if(pixmapItem){ + relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + pixmapItem->uuid().toString() + ".png"); + continue; + } + + UBGraphicsSvgItem* svgItem = qgraphicsitem_cast(item); + if(svgItem){ + relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg"); + continue; } } diff --git a/src/domain/UBGraphicsSvgItem.cpp b/src/domain/UBGraphicsSvgItem.cpp index 00bcdaae..7344514e 100644 --- a/src/domain/UBGraphicsSvgItem.cpp +++ b/src/domain/UBGraphicsSvgItem.cpp @@ -29,6 +29,13 @@ #include "UBGraphicsItemDelegate.h" #include "UBGraphicsPixmapItem.h" +#include "core/UBApplication.h" +#include "core/UBPersistenceManager.h" + +#include "board/UBBoardController.h" + +#include "frameworks/UBFileSystemUtils.h" + #include "core/memcheck.h" UBGraphicsSvgItem::UBGraphicsSvgItem(const QString& pFilePath, QGraphicsItem* parent) @@ -217,3 +224,11 @@ void UBGraphicsSvgItem::setUuid(const QUuid &pUuid) UBItem::setUuid(pUuid); setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene } + + +void UBGraphicsSvgItem::clearSource() +{ + QString fileName = UBPersistenceManager::imageDirectory + "/" + uuid().toString() + ".svg"; + QString diskPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + fileName; + UBFileSystemUtils::deleteFile(diskPath); +} diff --git a/src/domain/UBGraphicsSvgItem.h b/src/domain/UBGraphicsSvgItem.h index ef805bd6..2d9a4dc8 100644 --- a/src/domain/UBGraphicsSvgItem.h +++ b/src/domain/UBGraphicsSvgItem.h @@ -70,6 +70,8 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi virtual void setUuid(const QUuid &pUuid); + virtual void clearSource(); + protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -80,8 +82,6 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); -// UBGraphicsItemDelegate* mDelegate; - QByteArray mFileData; }; diff --git a/src/domain/UBGraphicsTextItemUndoCommand.h b/src/domain/UBGraphicsTextItemUndoCommand.h index 5b1d8c53..85e54714 100644 --- a/src/domain/UBGraphicsTextItemUndoCommand.h +++ b/src/domain/UBGraphicsTextItemUndoCommand.h @@ -25,18 +25,18 @@ #define UBGRAPHICSTEXTITEMUNDOCOMMAND_H_ #include -#include "UBAbstractUndoCommand.h" +#include "UBUndoCommand.h" #include "UBGraphicsTextItem.h" -class UBGraphicsTextItemUndoCommand : public UBAbstractUndoCommand +class UBGraphicsTextItemUndoCommand : public UBUndoCommand { public: UBGraphicsTextItemUndoCommand(UBGraphicsTextItem *textItem); virtual ~UBGraphicsTextItemUndoCommand(); - virtual UndoType getType() { return undotype_GRAPHICTEXTITEM; }; + virtual int getType() const { return UBUndoType::undotype_GRAPHICTEXTITEM; }; protected: virtual void undo(); diff --git a/src/domain/UBGraphicsWidgetItem.cpp b/src/domain/UBGraphicsWidgetItem.cpp index dcaf3a18..204def5f 100644 --- a/src/domain/UBGraphicsWidgetItem.cpp +++ b/src/domain/UBGraphicsWidgetItem.cpp @@ -149,6 +149,7 @@ QUrl UBGraphicsWidgetItem::widgetUrl() { return mWidgetUrl; } + QString UBGraphicsWidgetItem::mainHtmlFileName() { return mMainHtmlFileName; @@ -272,7 +273,8 @@ bool UBGraphicsWidgetItem::isDropableData(const QMimeData *data) const return mUniboardAPI->isDropableData(data); } -QUrl UBGraphicsWidgetItem::getOwnFolder() const { +QUrl UBGraphicsWidgetItem::getOwnFolder() const +{ return ownFolder; } diff --git a/src/domain/UBGraphicsWidgetItem.h b/src/domain/UBGraphicsWidgetItem.h index 65da2bd7..502d2aa2 100644 --- a/src/domain/UBGraphicsWidgetItem.h +++ b/src/domain/UBGraphicsWidgetItem.h @@ -69,6 +69,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe QUrl mainHtml(); void loadMainHtml(); QUrl widgetUrl(); + void widgetUrl(QUrl url) { mWidgetUrl = url; } QString mainHtmlFileName(); bool canBeContent(); @@ -130,7 +131,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe type_WIN = 1, // 0001 type_MAC = 2, // 0010 type_UNIX = 4, // 0100 - type_ALL = 7, // 0111 + type_ALL = 7 // 0111 }; bool mFirstReleaseAfterMove; diff --git a/src/domain/UBPageSizeUndoCommand.h b/src/domain/UBPageSizeUndoCommand.h index 35e46bda..1abbe7a2 100644 --- a/src/domain/UBPageSizeUndoCommand.h +++ b/src/domain/UBPageSizeUndoCommand.h @@ -25,18 +25,18 @@ #define UBPageSizeUndoCommand_H_ #include -#include "UBAbstractUndoCommand.h" +#include "UBUndoCommand.h" class UBGraphicsScene; -class UBPageSizeUndoCommand : public UBAbstractUndoCommand +class UBPageSizeUndoCommand : public UBUndoCommand { public: UBPageSizeUndoCommand(UBGraphicsScene* pScene, const QSize& previousSize, const QSize& newSize); virtual ~UBPageSizeUndoCommand(); - virtual UndoType getType() { return undotype_PAGESIZE; }; + virtual int getType() { return UBUndoType::undotype_PAGESIZE; }; protected: virtual void undo(); diff --git a/src/domain/UBAbstractUndoCommand.cpp b/src/domain/UBUndoCommand.cpp similarity index 76% rename from src/domain/UBAbstractUndoCommand.cpp rename to src/domain/UBUndoCommand.cpp index 54083211..9d641258 100644 --- a/src/domain/UBAbstractUndoCommand.cpp +++ b/src/domain/UBUndoCommand.cpp @@ -21,30 +21,17 @@ -#include "UBAbstractUndoCommand.h" +#include "UBUndoCommand.h" #include "core/memcheck.h" -UBAbstractUndoCommand::UBAbstractUndoCommand() +UBUndoCommand::UBUndoCommand(QUndoCommand* parent):QUndoCommand(parent) { // NOOP } -UBAbstractUndoCommand::~UBAbstractUndoCommand() +UBUndoCommand::~UBUndoCommand() { // NOOP } - -void UBAbstractUndoCommand::undo() -{ - // NOOP -} - -void UBAbstractUndoCommand::redo() -{ - // NOOP -} - -//void UBAbstractUndoCommand::UndoType getType(UndoType type); - diff --git a/src/domain/UBAbstractUndoCommand.h b/src/domain/UBUndoCommand.h similarity index 62% rename from src/domain/UBAbstractUndoCommand.h rename to src/domain/UBUndoCommand.h index a544c52b..80a989ae 100644 --- a/src/domain/UBAbstractUndoCommand.h +++ b/src/domain/UBUndoCommand.h @@ -25,30 +25,16 @@ #define UBABSTRACTUNDOCOMMAND_H_ #include +#include -class UBAbstractUndoCommand : public QUndoCommand +class UBUndoCommand : public QUndoCommand { public: - UBAbstractUndoCommand(); - ~UBAbstractUndoCommand(); - - enum UndoType - { - undotype_UNKNOWN = 0, - undotype_DOCUMENT = 1, - undotype_GRAPHICITEMTRANSFORM = 2, - undotype_GRAPHICITEM = 3, - undotype_GRAPHICTEXTITEM = 4, - undotype_PAGESIZE = 5, - undotype_GRAPHICSGROUPITEM = 6 - }; - - virtual UndoType getType() const { return undotype_UNKNOWN; } - - protected: - virtual void undo(); - virtual void redo(); + UBUndoCommand(QUndoCommand *parent = 0); + ~UBUndoCommand(); + + virtual int getType() const { return UBUndoType::undotype_UNKNOWN; } }; diff --git a/src/domain/domain.pri b/src/domain/domain.pri index 93172f49..b525dfd6 100644 --- a/src/domain/domain.pri +++ b/src/domain/domain.pri @@ -14,7 +14,6 @@ HEADERS += src/domain/UBGraphicsScene.h \ src/domain/UBResizableGraphicsItem.h \ src/domain/UBGraphicsStroke.h \ src/domain/UBGraphicsMediaItem.h \ - src/domain/UBAbstractUndoCommand.h \ src/domain/UBGraphicsGroupContainerItem.h \ src/domain/UBGraphicsGroupContainerItemDelegate.h \ src/domain/UBGraphicsStrokesGroup.h \ @@ -24,7 +23,8 @@ HEADERS += src/domain/UBGraphicsScene.h \ src/domain/UBGraphicsDelegateFrame.h \ src/domain/UBGraphicsWidgetItemDelegate.h \ src/domain/UBGraphicsMediaItemDelegate.h \ - src/domain/UBSelectionFrame.h + src/domain/UBSelectionFrame.h \ + src/domain/UBUndoCommand.h SOURCES += src/domain/UBGraphicsScene.cpp \ src/domain/UBGraphicsItemUndoCommand.cpp \ @@ -42,7 +42,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \ src/domain/UBResizableGraphicsItem.cpp \ src/domain/UBGraphicsStroke.cpp \ src/domain/UBGraphicsMediaItem.cpp \ - src/domain/UBAbstractUndoCommand.cpp \ src/domain/UBGraphicsGroupContainerItem.cpp \ src/domain/UBGraphicsGroupContainerItemDelegate.cpp \ src/domain/UBGraphicsStrokesGroup.cpp \ @@ -52,4 +51,5 @@ SOURCES += src/domain/UBGraphicsScene.cpp \ src/domain/UBGraphicsMediaItemDelegate.cpp \ src/domain/UBGraphicsDelegateFrame.cpp \ src/domain/UBGraphicsWidgetItemDelegate.cpp \ - src/domain/UBSelectionFrame.cpp + src/domain/UBSelectionFrame.cpp \ + src/domain/UBUndoCommand.cpp diff --git a/src/gui/UBStylusPalette.cpp b/src/gui/UBStylusPalette.cpp index 1cf47b63..b64f604c 100644 --- a/src/gui/UBStylusPalette.cpp +++ b/src/gui/UBStylusPalette.cpp @@ -66,17 +66,17 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient) if(!UBPlatformUtils::hasVirtualKeyboard()) { - groupActions(); + groupActions(); } else { - // VirtualKeyboard action is not in group - // So, groupping all buttons, except last - mButtonGroup = new QButtonGroup(this); - for(int i=0; i < mButtons.size()-1; i++) - { - mButtonGroup->addButton(mButtons[i], i); - } + // VirtualKeyboard action is not in group + // So, groupping all buttons, except last + mButtonGroup = new QButtonGroup(this); + for(int i=0; i < mButtons.size()-1; i++) + { + mButtonGroup->addButton(mButtons[i], i); + } connect(mButtonGroup, SIGNAL(buttonClicked(int)), this, SIGNAL(buttonGroupClicked(int))); } @@ -93,23 +93,28 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient) void UBStylusPalette::initPosition() { - if(!UBSettings::settings()->appToolBarOrientationVertical->get().toBool()) - { - QWidget* pParentW = parentWidget(); - if(NULL != pParentW) - { - mCustomPosition = true; - QPoint pos; - int parentWidth = pParentW->width(); - int parentHeight = pParentW->height(); - int posX = (parentWidth / 2) - (width() / 2); - int posY = parentHeight - border() - height(); - - pos.setX(posX); - pos.setY(posY); - moveInsideParent(pos); - } + QWidget* pParentW = parentWidget(); + if(!pParentW) return ; + + mCustomPosition = true; + + QPoint pos; + int parentWidth = pParentW->width(); + int parentHeight = pParentW->height(); + + if(UBSettings::settings()->appToolBarOrientationVertical->get().toBool()){ + int posX = border(); + int posY = (parentHeight / 2) - (height() / 2); + pos.setX(posX); + pos.setY(posY); + } + else { + int posX = (parentWidth / 2) - (width() / 2); + int posY = parentHeight - border() - height(); + pos.setX(posX); + pos.setY(posY); } + moveInsideParent(pos); } UBStylusPalette::~UBStylusPalette()