persistence of not required media on disk. Second step updated the cleanSource methods in classes that handle files on disk

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent eb5bebbca3
commit 0428f938d2
  1. 10
      src/board/UBBoardController.cpp
  2. 2
      src/core/UBPersistenceManager.cpp
  3. 2
      src/core/UBPersistenceManager.h
  4. 15
      src/domain/UBGraphicsPixmapItem.cpp
  5. 2
      src/domain/UBGraphicsPixmapItem.h
  6. 9
      src/domain/UBGraphicsProxyWidget.cpp
  7. 1
      src/domain/UBGraphicsProxyWidget.h
  8. 15
      src/domain/UBGraphicsSvgItem.cpp
  9. 4
      src/domain/UBGraphicsSvgItem.h
  10. 3
      src/domain/UBGraphicsWidgetItem.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"
@ -1325,6 +1324,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);
@ -2143,7 +2149,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);

@ -859,7 +859,7 @@ bool UBPersistenceManager::addFileToDocument(UBDocumentProxy* pDocumentProxy,
}
}
bool UBPersistenceManager::addGraphicsWidgteToDocument(UBDocumentProxy *pDocumentProxy,
bool UBPersistenceManager::addGraphicsWidgetToDocument(UBDocumentProxy *pDocumentProxy,
QString path,
QUuid objectUuid,
QString& destinationPath)

@ -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:

@ -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);
}

@ -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);

@ -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<UBGraphicsScene*>(QGraphicsItem::scene());
}

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

@ -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);
}

@ -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;
};

@ -272,7 +272,8 @@ bool UBGraphicsWidgetItem::isDropableData(const QMimeData *data) const
return mUniboardAPI->isDropableData(data);
}
QUrl UBGraphicsWidgetItem::getOwnFolder() const {
QUrl UBGraphicsWidgetItem::getOwnFolder() const
{
return ownFolder;
}

Loading…
Cancel
Save