Merge branch 'OEFUniboard' of github.com:stayonshadow/PrivateBoard into OEFUniboard

preferencesAboutTextFull
Didier Clerc 11 years ago
commit c39ba64fa6
  1. 24
      src/adaptors/UBImportAdaptor.cpp
  2. 23
      src/board/UBBoardController.cpp
  3. 2
      src/board/UBBoardController.h
  4. 9
      src/core/UB.h
  5. 73
      src/core/UBPersistenceManager.cpp
  6. 2
      src/core/UBPersistenceManager.h
  7. 7
      src/domain/UBGraphicsItemGroupUndoCommand.cpp
  8. 6
      src/domain/UBGraphicsItemGroupUndoCommand.h
  9. 2
      src/domain/UBGraphicsItemTransformUndoCommand.cpp
  10. 6
      src/domain/UBGraphicsItemTransformUndoCommand.h
  11. 10
      src/domain/UBGraphicsItemUndoCommand.cpp
  12. 6
      src/domain/UBGraphicsItemUndoCommand.h
  13. 2
      src/domain/UBGraphicsMediaItem.h
  14. 15
      src/domain/UBGraphicsPixmapItem.cpp
  15. 2
      src/domain/UBGraphicsPixmapItem.h
  16. 9
      src/domain/UBGraphicsProxyWidget.cpp
  17. 1
      src/domain/UBGraphicsProxyWidget.h
  18. 36
      src/domain/UBGraphicsScene.cpp
  19. 15
      src/domain/UBGraphicsSvgItem.cpp
  20. 4
      src/domain/UBGraphicsSvgItem.h
  21. 6
      src/domain/UBGraphicsTextItemUndoCommand.h
  22. 4
      src/domain/UBGraphicsWidgetItem.cpp
  23. 3
      src/domain/UBGraphicsWidgetItem.h
  24. 6
      src/domain/UBPageSizeUndoCommand.h
  25. 19
      src/domain/UBUndoCommand.cpp
  26. 24
      src/domain/UBUndoCommand.h
  27. 8
      src/domain/domain.pri
  28. 19
      src/gui/UBStylusPalette.cpp

@ -53,27 +53,3 @@ UBDocumentBasedImportAdaptor::UBDocumentBasedImportAdaptor(QObject *parent)
{ {
// NOOP // 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;
}
*/

@ -51,7 +51,6 @@
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsItemUndoCommand.h" #include "domain/UBGraphicsItemUndoCommand.h"
#include "domain/UBGraphicsProxyWidget.h"
#include "domain/UBGraphicsSvgItem.h" #include "domain/UBGraphicsSvgItem.h"
#include "domain/UBGraphicsWidgetItem.h" #include "domain/UBGraphicsWidgetItem.h"
#include "domain/UBGraphicsMediaItem.h" #include "domain/UBGraphicsMediaItem.h"
@ -1319,6 +1318,7 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
Q_UNUSED(internalData) Q_UNUSED(internalData)
QString widgetUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapper(sUrl, mimeType, size); QString widgetUrl = UBGraphicsW3CWidgetItem::createNPAPIWrapper(sUrl, mimeType, size);
UBFileSystemUtils::deleteFile(sourceUrl.toLocalFile());
emit npapiWidgetCreated(widgetUrl); emit npapiWidgetCreated(widgetUrl);
if (widgetUrl.length() > 0) if (widgetUrl.length() > 0)
@ -1326,6 +1326,13 @@ UBItem *UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QUrl
UBGraphicsWidgetItem *widgetItem = mActiveScene->addW3CWidget(QUrl::fromLocalFile(widgetUrl), pPos); UBGraphicsWidgetItem *widgetItem = mActiveScene->addW3CWidget(QUrl::fromLocalFile(widgetUrl), pPos);
widgetItem->setUuid(QUuid::createUuid()); widgetItem->setUuid(QUuid::createUuid());
widgetItem->setSourceUrl(QUrl::fromLocalFile(widgetUrl)); 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); UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
@ -1551,11 +1558,11 @@ void UBBoardController::moveSceneToIndex(int source, int target)
} }
} }
void UBBoardController::fitUniqIems(const QUndoCommand *parent, QSet<QGraphicsItem*> &itms) void UBBoardController::findUniquesItems(const QUndoCommand *parent, QSet<QGraphicsItem*> &itms)
{ {
if (parent->childCount()) { if (parent->childCount()) {
for (int i = 0; i < parent->childCount(); i++) { 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<QGraphicsIt
return; return;
} }
const UBAbstractUndoCommand *abstractCmd = static_cast<const UBAbstractUndoCommand*>(parent); const UBUndoCommand *undoCmd = static_cast<const UBUndoCommand*>(parent);
if(abstractCmd->getType() != UBAbstractUndoCommand::undotype_GRAPHICITEM) if(undoCmd->getType() != UBUndoType::undotype_GRAPHICITEM)
return; return;
const UBGraphicsItemUndoCommand *cmd = static_cast<const UBGraphicsItemUndoCommand*>(parent); const UBGraphicsItemUndoCommand *cmd = dynamic_cast<const UBGraphicsItemUndoCommand*>(parent);
// go through all added and removed objects, for create list of unique objects // 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. // grouped items will be deleted by groups, so we don't need do delete that items.
@ -1594,7 +1601,7 @@ void UBBoardController::ClearUndoStack()
QSet<QGraphicsItem*> uniqueItems; QSet<QGraphicsItem*> uniqueItems;
// go through all stack command // go through all stack command
for (int i = 0; i < UBApplication::undoStack->count(); i++) { 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. // 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(); QUuid uuid = QUuid::createUuid();
QString destPath; QString destPath;
if (!UBPersistenceManager::persistenceManager()->addGraphicsWidgteToDocument(selectedDocument(), pUrl.toLocalFile(), uuid, destPath)) if (!UBPersistenceManager::persistenceManager()->addGraphicsWidgetToDocument(selectedDocument(), pUrl.toLocalFile(), uuid, destPath))
return NULL; return NULL;
QUrl newUrl = QUrl::fromLocalFile(destPath); QUrl newUrl = QUrl::fromLocalFile(destPath);

@ -160,7 +160,7 @@ class UBBoardController : public UBDocumentContainer
void notifyPageChanged(); void notifyPageChanged();
void displayMetaData(QMap<QString, QString> metadatas); void displayMetaData(QMap<QString, QString> metadatas);
void fitUniqIems(const QUndoCommand *parent, QSet<QGraphicsItem *> &itms); void findUniquesItems(const QUndoCommand *parent, QSet<QGraphicsItem *> &itms);
void ClearUndoStack(); void ClearUndoStack();
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false);

@ -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_ */ #endif /* UB_H_ */

@ -40,6 +40,11 @@
#include "adaptors/UBThumbnailAdaptor.h" #include "adaptors/UBThumbnailAdaptor.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.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/UBBoardController.h"
#include "board/UBBoardPaletteManager.h" #include "board/UBBoardPaletteManager.h"
@ -396,12 +401,14 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
foreach(int index, compactedIndexes) foreach(int index, compactedIndexes)
{ {
// trig the reload of the thumbnails
emit documentSceneWillBeDeleted(proxy, index); emit documentSceneWillBeDeleted(proxy, index);
} }
QString sourceGroupName = proxy->metaData(UBSettings::documentGroupName).toString(); QString sourceGroupName = proxy->metaData(UBSettings::documentGroupName).toString();
QString sourceName = proxy->metaData(UBSettings::documentName).toString(); QString sourceName = proxy->metaData(UBSettings::documentName).toString();
UBDocumentProxy *trashDocProxy = createDocument(UBSettings::trashedDocumentGroupNamePrefix + sourceGroupName, sourceName, false); UBDocumentProxy *trashDocProxy = createDocument(UBSettings::trashedDocumentGroupNamePrefix + sourceGroupName, sourceName, false);
generatePathIfNeeded(trashDocProxy);
foreach(int index, compactedIndexes) foreach(int index, compactedIndexes)
{ {
@ -418,7 +425,7 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
QDir d = fi.dir(); QDir d = fi.dir();
d.mkpath(d.absolutePath()); d.mkpath(d.absolutePath());
QFile::copy(source, target); Q_ASSERT(QFile::rename(source, target));
} }
insertDocumentSceneAt(trashDocProxy, scene, trashDocProxy->pageCount()); insertDocumentSceneAt(trashDocProxy, scene, trashDocProxy->pageCount());
@ -467,6 +474,8 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
} }
void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int index) void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int index)
{ {
checkIfDocumentRepositoryExists(); checkIfDocumentRepositoryExists();
@ -483,6 +492,66 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in
copyPage(proxy, index , index + 1); 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<UBGraphicsMediaItem*> (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<UBGraphicsWidgetItem*>(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<UBGraphicsPixmapItem*>(item);
if(pixmapItem){
pixmapItem->setUuid(QUuid::createUuid());
continue;
}
UBGraphicsSvgItem* svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*>(item);
if(svgItem){
svgItem->setUuid(QUuid::createUuid());
continue;
}
}
scene->setModified(true);
persistDocumentScene(proxy,scene, index + 1);
proxy->incPageCount(); proxy->incPageCount();
emit documentSceneCreated(proxy, index + 1); 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, QString path,
QUuid objectUuid, QUuid objectUuid,
QString& destinationPath) QString& destinationPath)

@ -103,7 +103,7 @@ class UBPersistenceManager : public QObject
virtual bool isEmpty(UBDocumentProxy* pDocumentProxy); virtual bool isEmpty(UBDocumentProxy* pDocumentProxy);
virtual void purgeEmptyDocuments(); 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); bool addFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, const QString& subdir, QUuid objectUuid, QString& destinationPath, QByteArray* data = NULL);
signals: signals:

@ -28,9 +28,10 @@
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) : UBGraphicsItemGroupUndoCommand::UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated) : UBUndoCommand()
mScene (pScene), mGroup(pGroupCreated), mFirstRedo(true) , mScene (pScene)
, mGroup(pGroupCreated)
, mFirstRedo(true)
{ {
if (pGroupCreated->childItems().count()) { if (pGroupCreated->childItems().count()) {
foreach (QGraphicsItem *item, pGroupCreated->childItems()) { foreach (QGraphicsItem *item, pGroupCreated->childItems()) {

@ -25,18 +25,18 @@
#define UBGRAPHICSITEMGROUPUNDOCOMMAND_H #define UBGRAPHICSITEMGROUPUNDOCOMMAND_H
#include <QList> #include <QList>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsGroupContainerItem; class UBGraphicsGroupContainerItem;
class UBGraphicsItemGroupUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemGroupUndoCommand : public UBUndoCommand
{ {
public: public:
UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated); UBGraphicsItemGroupUndoCommand(UBGraphicsScene *pScene, UBGraphicsGroupContainerItem *pGroupCreated);
virtual ~UBGraphicsItemGroupUndoCommand(); virtual ~UBGraphicsItemGroupUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICSGROUPITEM; } virtual int getType() const { return UBUndoType::undotype_GRAPHICSGROUPITEM; }
protected: protected:
virtual void undo(); virtual void undo();

@ -29,7 +29,7 @@
UBGraphicsItemTransformUndoCommand::UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem, UBGraphicsItemTransformUndoCommand::UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem,
const QPointF& prevPos, const QTransform& prevTransform, const qreal& prevZValue, const QPointF& prevPos, const QTransform& prevTransform, const qreal& prevZValue,
const QSizeF& prevSize) const QSizeF& prevSize):UBUndoCommand()
{ {
mItem = pItem; mItem = pItem;
mPreviousTransform = prevTransform; mPreviousTransform = prevTransform;

@ -27,10 +27,10 @@
#include <QtGui> #include <QtGui>
#include "UBResizableGraphicsItem.h" #include "UBResizableGraphicsItem.h"
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemTransformUndoCommand : public UBUndoCommand
{ {
public: public:
UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem, UBGraphicsItemTransformUndoCommand(QGraphicsItem* pItem,
@ -40,7 +40,7 @@ class UBGraphicsItemTransformUndoCommand : public UBAbstractUndoCommand
const QSizeF& prevSize = QSizeF()); const QSizeF& prevSize = QSizeF());
virtual ~UBGraphicsItemTransformUndoCommand(); virtual ~UBGraphicsItemTransformUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICITEMTRANSFORM; } virtual int getType() const { return UBUndoType::undotype_GRAPHICITEMTRANSFORM; }
protected: protected:
virtual void undo(); virtual void undo();

@ -35,9 +35,8 @@
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsPolygonItem.h" #include "domain/UBGraphicsPolygonItem.h"
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, const QSet<QGraphicsItem*>& pRemovedItems, const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap): UBUndoCommand()
const QSet<QGraphicsItem*>& pAddedItems, const GroupDataTable &groupsMap) , mScene(pScene)
: mScene(pScene)
, mRemovedItems(pRemovedItems - pAddedItems) , mRemovedItems(pRemovedItems - pAddedItems)
, mAddedItems(pAddedItems - pRemovedItems) , mAddedItems(pAddedItems - pRemovedItems)
, mExcludedFromGroup(groupsMap) , mExcludedFromGroup(groupsMap)
@ -57,9 +56,8 @@ UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, co
} }
} }
UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, UBGraphicsItemUndoCommand::UBGraphicsItemUndoCommand(UBGraphicsScene* pScene, QGraphicsItem* pRemovedItem, QGraphicsItem* pAddedItem) : UBUndoCommand()
QGraphicsItem* pAddedItem) : , mScene(pScene)
mScene(pScene)
{ {
if (pRemovedItem) if (pRemovedItem)

@ -25,14 +25,14 @@
#define UBGRAPHICSITEMUNDOCOMMAND_H_ #define UBGRAPHICSITEMUNDOCOMMAND_H_
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
#include "UBGraphicsGroupContainerItem.h" #include "UBGraphicsGroupContainerItem.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand class UBGraphicsItemUndoCommand : public UBUndoCommand
{ {
public: public:
typedef QMultiMap<UBGraphicsGroupContainerItem*, QUuid> GroupDataTable; typedef QMultiMap<UBGraphicsGroupContainerItem*, QUuid> GroupDataTable;
@ -48,7 +48,7 @@ class UBGraphicsItemUndoCommand : public UBAbstractUndoCommand
QSet<QGraphicsItem*> GetAddedList() const { return mAddedItems; } QSet<QGraphicsItem*> GetAddedList() const { return mAddedItems; }
QSet<QGraphicsItem*> GetRemovedList() const { return mRemovedItems; } QSet<QGraphicsItem*> GetRemovedList() const { return mRemovedItems; }
virtual UndoType getType() { return undotype_GRAPHICITEM; } virtual int getType() const { return UBUndoType::undotype_GRAPHICITEM; }
protected: protected:
virtual void undo(); virtual void undo();

@ -57,6 +57,8 @@ public:
return mMediaFileUrl; return mMediaFileUrl;
} }
virtual void mediaFileUrl(QUrl url){mMediaFileUrl=url;}
Phonon::MediaObject* mediaObject() const Phonon::MediaObject* mediaObject() const
{ {
return mMediaObject; return mMediaObject;

@ -31,6 +31,13 @@
#include "UBGraphicsItemDelegate.h" #include "UBGraphicsItemDelegate.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "board/UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent) UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
@ -164,3 +171,11 @@ qreal UBGraphicsPixmapItem::opacity() const
{ {
return QGraphicsPixmapItem::opacity(); return QGraphicsPixmapItem::opacity();
} }
void UBGraphicsPixmapItem::clearSource()
{
QString fileName = UBPersistenceManager::imageDirectory + "/" + uuid().toString() + ".png";
QString diskPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + fileName;
UBFileSystemUtils::deleteFile(diskPath);
}

@ -57,7 +57,7 @@ class UBGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public
void setOpacity(qreal op); void setOpacity(qreal op);
qreal opacity() const; qreal opacity() const;
virtual void clearSource(){;} virtual void clearSource();
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);

@ -30,6 +30,13 @@
#include "UBGraphicsDelegateFrame.h" #include "UBGraphicsDelegateFrame.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent) UBGraphicsProxyWidget::UBGraphicsProxyWidget(QGraphicsItem* parent)
@ -198,5 +205,3 @@ UBGraphicsScene* UBGraphicsProxyWidget::scene()
{ {
return static_cast<UBGraphicsScene*>(QGraphicsItem::scene()); return static_cast<UBGraphicsScene*>(QGraphicsItem::scene());
} }

@ -44,7 +44,6 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
virtual void clearSource(){;}
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
protected: protected:

@ -2089,11 +2089,39 @@ QList<QUrl> UBGraphicsScene::relativeDependencies() const
while (itItems.hasNext()) while (itItems.hasNext())
{ {
UBGraphicsMediaItem *videoItem = qgraphicsitem_cast<UBGraphicsMediaItem*> (itItems.next()); QGraphicsItem* item = itItems.next();
UBGraphicsMediaItem *mediaItem = qgraphicsitem_cast<UBGraphicsMediaItem*> (item);
if (videoItem && videoItem->mediaFileUrl().isRelative()) if (mediaItem){
{ QString completeFileName = QFileInfo(mediaItem->mediaFileUrl().toLocalFile()).fileName();
relativePathes << videoItem->mediaFileUrl(); QString path;
if(mediaItem->getMediaType() == UBGraphicsMediaItem::mediaType_Video)
path = UBPersistenceManager::videoDirectory + "/";
else
path = UBPersistenceManager::audioDirectory + "/";
relativePathes << QUrl(path + completeFileName);
continue;
}
UBGraphicsWidgetItem* widget = qgraphicsitem_cast<UBGraphicsWidgetItem*>(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<UBGraphicsPixmapItem*>(item);
if(pixmapItem){
relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + pixmapItem->uuid().toString() + ".png");
continue;
}
UBGraphicsSvgItem* svgItem = qgraphicsitem_cast<UBGraphicsSvgItem*>(item);
if(svgItem){
relativePathes << QUrl(UBPersistenceManager::imageDirectory + "/" + svgItem->uuid().toString() + ".svg");
continue;
} }
} }

@ -29,6 +29,13 @@
#include "UBGraphicsItemDelegate.h" #include "UBGraphicsItemDelegate.h"
#include "UBGraphicsPixmapItem.h" #include "UBGraphicsPixmapItem.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBGraphicsSvgItem::UBGraphicsSvgItem(const QString& pFilePath, QGraphicsItem* parent) UBGraphicsSvgItem::UBGraphicsSvgItem(const QString& pFilePath, QGraphicsItem* parent)
@ -217,3 +224,11 @@ void UBGraphicsSvgItem::setUuid(const QUuid &pUuid)
UBItem::setUuid(pUuid); UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene 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);
}

@ -70,6 +70,8 @@ class UBGraphicsSvgItem: public QGraphicsSvgItem, public UBItem, public UBGraphi
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
virtual void clearSource();
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); 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); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
// UBGraphicsItemDelegate* mDelegate;
QByteArray mFileData; QByteArray mFileData;
}; };

@ -25,18 +25,18 @@
#define UBGRAPHICSTEXTITEMUNDOCOMMAND_H_ #define UBGRAPHICSTEXTITEMUNDOCOMMAND_H_
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
#include "UBGraphicsTextItem.h" #include "UBGraphicsTextItem.h"
class UBGraphicsTextItemUndoCommand : public UBAbstractUndoCommand class UBGraphicsTextItemUndoCommand : public UBUndoCommand
{ {
public: public:
UBGraphicsTextItemUndoCommand(UBGraphicsTextItem *textItem); UBGraphicsTextItemUndoCommand(UBGraphicsTextItem *textItem);
virtual ~UBGraphicsTextItemUndoCommand(); virtual ~UBGraphicsTextItemUndoCommand();
virtual UndoType getType() { return undotype_GRAPHICTEXTITEM; }; virtual int getType() const { return UBUndoType::undotype_GRAPHICTEXTITEM; };
protected: protected:
virtual void undo(); virtual void undo();

@ -149,6 +149,7 @@ QUrl UBGraphicsWidgetItem::widgetUrl()
{ {
return mWidgetUrl; return mWidgetUrl;
} }
QString UBGraphicsWidgetItem::mainHtmlFileName() QString UBGraphicsWidgetItem::mainHtmlFileName()
{ {
return mMainHtmlFileName; return mMainHtmlFileName;
@ -272,7 +273,8 @@ bool UBGraphicsWidgetItem::isDropableData(const QMimeData *data) const
return mUniboardAPI->isDropableData(data); return mUniboardAPI->isDropableData(data);
} }
QUrl UBGraphicsWidgetItem::getOwnFolder() const { QUrl UBGraphicsWidgetItem::getOwnFolder() const
{
return ownFolder; return ownFolder;
} }

@ -69,6 +69,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
QUrl mainHtml(); QUrl mainHtml();
void loadMainHtml(); void loadMainHtml();
QUrl widgetUrl(); QUrl widgetUrl();
void widgetUrl(QUrl url) { mWidgetUrl = url; }
QString mainHtmlFileName(); QString mainHtmlFileName();
bool canBeContent(); bool canBeContent();
@ -130,7 +131,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
type_WIN = 1, // 0001 type_WIN = 1, // 0001
type_MAC = 2, // 0010 type_MAC = 2, // 0010
type_UNIX = 4, // 0100 type_UNIX = 4, // 0100
type_ALL = 7, // 0111 type_ALL = 7 // 0111
}; };
bool mFirstReleaseAfterMove; bool mFirstReleaseAfterMove;

@ -25,18 +25,18 @@
#define UBPageSizeUndoCommand_H_ #define UBPageSizeUndoCommand_H_
#include <QtGui> #include <QtGui>
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBPageSizeUndoCommand : public UBAbstractUndoCommand class UBPageSizeUndoCommand : public UBUndoCommand
{ {
public: public:
UBPageSizeUndoCommand(UBGraphicsScene* pScene, const QSize& previousSize, const QSize& newSize); UBPageSizeUndoCommand(UBGraphicsScene* pScene, const QSize& previousSize, const QSize& newSize);
virtual ~UBPageSizeUndoCommand(); virtual ~UBPageSizeUndoCommand();
virtual UndoType getType() { return undotype_PAGESIZE; }; virtual int getType() { return UBUndoType::undotype_PAGESIZE; };
protected: protected:
virtual void undo(); virtual void undo();

@ -21,30 +21,17 @@
#include "UBAbstractUndoCommand.h" #include "UBUndoCommand.h"
#include "core/memcheck.h" #include "core/memcheck.h"
UBAbstractUndoCommand::UBAbstractUndoCommand() UBUndoCommand::UBUndoCommand(QUndoCommand* parent):QUndoCommand(parent)
{ {
// NOOP // NOOP
} }
UBAbstractUndoCommand::~UBAbstractUndoCommand() UBUndoCommand::~UBUndoCommand()
{ {
// NOOP // NOOP
} }
void UBAbstractUndoCommand::undo()
{
// NOOP
}
void UBAbstractUndoCommand::redo()
{
// NOOP
}
//void UBAbstractUndoCommand::UndoType getType(UndoType type);

@ -25,30 +25,16 @@
#define UBABSTRACTUNDOCOMMAND_H_ #define UBABSTRACTUNDOCOMMAND_H_
#include <QtGui> #include <QtGui>
#include <core/UB.h>
class UBAbstractUndoCommand : public QUndoCommand class UBUndoCommand : public QUndoCommand
{ {
public: public:
UBAbstractUndoCommand(); UBUndoCommand(QUndoCommand *parent = 0);
~UBAbstractUndoCommand(); ~UBUndoCommand();
enum UndoType virtual int getType() const { return UBUndoType::undotype_UNKNOWN; }
{
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();
}; };

@ -14,7 +14,6 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBResizableGraphicsItem.h \ src/domain/UBResizableGraphicsItem.h \
src/domain/UBGraphicsStroke.h \ src/domain/UBGraphicsStroke.h \
src/domain/UBGraphicsMediaItem.h \ src/domain/UBGraphicsMediaItem.h \
src/domain/UBAbstractUndoCommand.h \
src/domain/UBGraphicsGroupContainerItem.h \ src/domain/UBGraphicsGroupContainerItem.h \
src/domain/UBGraphicsGroupContainerItemDelegate.h \ src/domain/UBGraphicsGroupContainerItemDelegate.h \
src/domain/UBGraphicsStrokesGroup.h \ src/domain/UBGraphicsStrokesGroup.h \
@ -24,7 +23,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsDelegateFrame.h \ src/domain/UBGraphicsDelegateFrame.h \
src/domain/UBGraphicsWidgetItemDelegate.h \ src/domain/UBGraphicsWidgetItemDelegate.h \
src/domain/UBGraphicsMediaItemDelegate.h \ src/domain/UBGraphicsMediaItemDelegate.h \
src/domain/UBSelectionFrame.h src/domain/UBSelectionFrame.h \
src/domain/UBUndoCommand.h
SOURCES += src/domain/UBGraphicsScene.cpp \ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsItemUndoCommand.cpp \ src/domain/UBGraphicsItemUndoCommand.cpp \
@ -42,7 +42,6 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBResizableGraphicsItem.cpp \ src/domain/UBResizableGraphicsItem.cpp \
src/domain/UBGraphicsStroke.cpp \ src/domain/UBGraphicsStroke.cpp \
src/domain/UBGraphicsMediaItem.cpp \ src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBGraphicsGroupContainerItem.cpp \ src/domain/UBGraphicsGroupContainerItem.cpp \
src/domain/UBGraphicsGroupContainerItemDelegate.cpp \ src/domain/UBGraphicsGroupContainerItemDelegate.cpp \
src/domain/UBGraphicsStrokesGroup.cpp \ src/domain/UBGraphicsStrokesGroup.cpp \
@ -52,4 +51,5 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsMediaItemDelegate.cpp \ src/domain/UBGraphicsMediaItemDelegate.cpp \
src/domain/UBGraphicsDelegateFrame.cpp \ src/domain/UBGraphicsDelegateFrame.cpp \
src/domain/UBGraphicsWidgetItemDelegate.cpp \ src/domain/UBGraphicsWidgetItemDelegate.cpp \
src/domain/UBSelectionFrame.cpp src/domain/UBSelectionFrame.cpp \
src/domain/UBUndoCommand.cpp

@ -92,24 +92,29 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient)
} }
void UBStylusPalette::initPosition() void UBStylusPalette::initPosition()
{
if(!UBSettings::settings()->appToolBarOrientationVertical->get().toBool())
{ {
QWidget* pParentW = parentWidget(); QWidget* pParentW = parentWidget();
if(NULL != pParentW) if(!pParentW) return ;
{
mCustomPosition = true; mCustomPosition = true;
QPoint pos; QPoint pos;
int parentWidth = pParentW->width(); int parentWidth = pParentW->width();
int parentHeight = pParentW->height(); int parentHeight = pParentW->height();
int posX = (parentWidth / 2) - (width() / 2);
int posY = parentHeight - border() - height();
if(UBSettings::settings()->appToolBarOrientationVertical->get().toBool()){
int posX = border();
int posY = (parentHeight / 2) - (height() / 2);
pos.setX(posX); pos.setX(posX);
pos.setY(posY); pos.setY(posY);
moveInsideParent(pos);
} }
else {
int posX = (parentWidth / 2) - (width() / 2);
int posY = parentHeight - border() - height();
pos.setX(posX);
pos.setY(posY);
} }
moveInsideParent(pos);
} }
UBStylusPalette::~UBStylusPalette() UBStylusPalette::~UBStylusPalette()

Loading…
Cancel
Save