parent
b6604dce59
commit
c4e771c8ad
@ -1,217 +1,219 @@ |
|||||||
/*
|
/*
|
||||||
* This program is free software: you can redistribute it and/or modify |
* This program is free software: you can redistribute it and/or modify |
||||||
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
||||||
* the Free Software Foundation, either version 3 of the License, or |
* the Free Software Foundation, either version 3 of the License, or |
||||||
* (at your option) any later version. |
* (at your option) any later version. |
||||||
* |
* |
||||||
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
* GNU General Public License for more details. |
* GNU General Public License for more details. |
||||||
* |
* |
||||||
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/ |
*/ |
||||||
|
|
||||||
#include "UBImportDocument.h" |
#include "UBImportDocument.h" |
||||||
#include "document/UBDocumentProxy.h" |
#include "document/UBDocumentProxy.h" |
||||||
|
|
||||||
#include "frameworks/UBFileSystemUtils.h" |
#include "frameworks/UBFileSystemUtils.h" |
||||||
|
|
||||||
#include "core/UBApplication.h" |
#include "core/UBApplication.h" |
||||||
#include "core/UBSettings.h" |
#include "core/UBSettings.h" |
||||||
#include "core/UBPersistenceManager.h" |
#include "core/UBPersistenceManager.h" |
||||||
|
|
||||||
#include "globals/UBGlobals.h" |
#include "globals/UBGlobals.h" |
||||||
|
|
||||||
THIRD_PARTY_WARNINGS_DISABLE |
THIRD_PARTY_WARNINGS_DISABLE |
||||||
#include "quazip.h" |
#include "quazip.h" |
||||||
#include "quazipfile.h" |
#include "quazipfile.h" |
||||||
#include "quazipfileinfo.h" |
#include "quazipfileinfo.h" |
||||||
THIRD_PARTY_WARNINGS_ENABLE |
THIRD_PARTY_WARNINGS_ENABLE |
||||||
|
|
||||||
#include "core/memcheck.h" |
#include "core/memcheck.h" |
||||||
|
|
||||||
UBImportDocument::UBImportDocument(QObject *parent) |
UBImportDocument::UBImportDocument(QObject *parent) |
||||||
:UBImportAdaptor(parent) |
:UBImportAdaptor(parent) |
||||||
{ |
{ |
||||||
// NOOP
|
// NOOP
|
||||||
} |
} |
||||||
|
|
||||||
UBImportDocument::~UBImportDocument() |
UBImportDocument::~UBImportDocument() |
||||||
{ |
{ |
||||||
// NOOP
|
// NOOP
|
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
QStringList UBImportDocument::supportedExtentions() |
QStringList UBImportDocument::supportedExtentions() |
||||||
{ |
{ |
||||||
return QStringList("ubz"); |
return QStringList("ubz"); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
QString UBImportDocument::importFileFilter() |
QString UBImportDocument::importFileFilter() |
||||||
{ |
{ |
||||||
return tr("Open-Sankore (*.ubz)"); |
return tr("Open-Sankore (*.ubz)"); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString& pDir) |
QString UBImportDocument::expandFileToDir(const QFile& pZipFile, const QString& pDir) |
||||||
{ |
{ |
||||||
|
|
||||||
QDir rootDir(pDir); |
QDir rootDir(pDir); |
||||||
QuaZip zip(pZipFile.fileName()); |
QuaZip zip(pZipFile.fileName()); |
||||||
|
|
||||||
if(!zip.open(QuaZip::mdUnzip)) |
if(!zip.open(QuaZip::mdUnzip)) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause zip.open(): " << zip.getZipError(); |
qWarning() << "Import failed. Cause zip.open(): " << zip.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
zip.setFileNameCodec("UTF-8"); |
zip.setFileNameCodec("UTF-8"); |
||||||
QuaZipFileInfo info; |
QuaZipFileInfo info; |
||||||
QuaZipFile file(&zip); |
QuaZipFile file(&zip); |
||||||
|
|
||||||
// TODO UB 4.x implement a mechanism that can replace an existing
|
// TODO UB 4.x implement a mechanism that can replace an existing
|
||||||
// document based on the UID of the document.
|
// document based on the UID of the document.
|
||||||
bool createNewDocument = true; |
bool createNewDocument = true; |
||||||
QString documentRootFolder; |
QString documentRootFolder; |
||||||
|
|
||||||
// first we search the metadata.rdf to check the document properties
|
// first we search the metadata.rdf to check the document properties
|
||||||
for(bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) |
for(bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) |
||||||
{ |
{ |
||||||
if(!zip.getCurrentFileInfo(&info)) |
if(!zip.getCurrentFileInfo(&info)) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: getCurrentFileInfo(): " << zip.getZipError(); |
qWarning() << "Import failed. Cause: getCurrentFileInfo(): " << zip.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
QFileInfo currentFileInfo(pDir + "/" + file.getActualFileName()); |
QFileInfo currentFileInfo(pDir + "/" + file.getActualFileName()); |
||||||
} |
} |
||||||
|
|
||||||
if (createNewDocument) |
if (createNewDocument) |
||||||
documentRootFolder = UBPersistenceManager::persistenceManager()->generateUniqueDocumentPath(); |
documentRootFolder = UBPersistenceManager::persistenceManager()->generateUniqueDocumentPath(); |
||||||
|
|
||||||
|
|
||||||
QFile out; |
QFile out; |
||||||
char c; |
char c; |
||||||
for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) |
for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) |
||||||
{ |
{ |
||||||
if(!zip.getCurrentFileInfo(&info)) |
if(!zip.getCurrentFileInfo(&info)) |
||||||
{ |
{ |
||||||
//TOD UB 4.3 O display error to user or use crash reporter
|
//TOD UB 4.3 O display error to user or use crash reporter
|
||||||
qWarning() << "Import failed. Cause: getCurrentFileInfo(): " << zip.getZipError(); |
qWarning() << "Import failed. Cause: getCurrentFileInfo(): " << zip.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
if(!file.open(QIODevice::ReadOnly)) |
if(!file.open(QIODevice::ReadOnly)) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: file.open(): " << zip.getZipError(); |
qWarning() << "Import failed. Cause: file.open(): " << zip.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
if(file.getZipError()!= UNZ_OK) |
if(file.getZipError()!= UNZ_OK) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: file.getFileName(): " << zip.getZipError(); |
qWarning() << "Import failed. Cause: file.getFileName(): " << zip.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
QString newFileName = documentRootFolder + "/" + file.getActualFileName(); |
QString newFileName = documentRootFolder + "/" + file.getActualFileName(); |
||||||
QFileInfo newFileInfo(newFileName); |
QFileInfo newFileInfo(newFileName); |
||||||
rootDir.mkpath(newFileInfo.absolutePath()); |
rootDir.mkpath(newFileInfo.absolutePath()); |
||||||
|
|
||||||
out.setFileName(newFileName); |
out.setFileName(newFileName); |
||||||
out.open(QIODevice::WriteOnly); |
out.open(QIODevice::WriteOnly); |
||||||
|
|
||||||
// Slow like hell (on GNU/Linux at least), but it is not my fault.
|
// Slow like hell (on GNU/Linux at least), but it is not my fault.
|
||||||
// Not ZIP/UNZIP package's fault either.
|
// Not ZIP/UNZIP package's fault either.
|
||||||
// The slowest thing here is out.putChar(c).
|
// The slowest thing here is out.putChar(c).
|
||||||
QByteArray outFileContent = file.readAll(); |
QByteArray outFileContent = file.readAll(); |
||||||
if (out.write(outFileContent) == -1) |
if (out.write(outFileContent) == -1) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: Unable to write file"; |
qWarning() << "Import failed. Cause: Unable to write file"; |
||||||
out.close(); |
out.close(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
while(file.getChar(&c)) |
while(file.getChar(&c)) |
||||||
out.putChar(c); |
out.putChar(c); |
||||||
|
|
||||||
out.close(); |
out.close(); |
||||||
|
|
||||||
if(file.getZipError()!=UNZ_OK) |
if(file.getZipError()!=UNZ_OK) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: " << zip.getZipError(); |
qWarning() << "Import failed. Cause: " << zip.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
if(!file.atEnd()) |
if(!file.atEnd()) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: read all but not EOF"; |
qWarning() << "Import failed. Cause: read all but not EOF"; |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
file.close(); |
file.close(); |
||||||
|
|
||||||
if(file.getZipError()!=UNZ_OK) |
if(file.getZipError()!=UNZ_OK) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: file.close(): " << file.getZipError(); |
qWarning() << "Import failed. Cause: file.close(): " << file.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
zip.close(); |
zip.close(); |
||||||
|
|
||||||
if(zip.getZipError()!=UNZ_OK) |
if(zip.getZipError()!=UNZ_OK) |
||||||
{ |
{ |
||||||
qWarning() << "Import failed. Cause: zip.close(): " << zip.getZipError(); |
qWarning() << "Import failed. Cause: zip.close(): " << zip.getZipError(); |
||||||
return ""; |
return ""; |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
return documentRootFolder; |
return documentRootFolder; |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString& pGroup) |
UBDocumentProxy* UBImportDocument::importFile(const QFile& pFile, const QString& pGroup) |
||||||
{ |
{ |
||||||
Q_UNUSED(pGroup); // group is defined in the imported file
|
Q_UNUSED(pGroup); // group is defined in the imported file
|
||||||
|
|
||||||
QFileInfo fi(pFile); |
QFileInfo fi(pFile); |
||||||
UBApplication::showMessage(tr("Importing file %1...").arg(fi.baseName()), true); |
UBApplication::showMessage(tr("Importing file %1...").arg(fi.baseName()), true); |
||||||
|
|
||||||
// first unzip the file to the correct place
|
// first unzip the file to the correct place
|
||||||
QString path = UBSettings::settings()->uniboardDocumentDirectory(); |
QString path = UBSettings::settings()->uniboardDocumentDirectory(); |
||||||
|
|
||||||
QString documentRootFolder = expandFileToDir(pFile, path); |
QString documentRootFolder = expandFileToDir(pFile, path); |
||||||
|
|
||||||
if(!documentRootFolder.length()){ |
if(!documentRootFolder.length()){ |
||||||
UBApplication::showMessage(tr("Import of file %1 failed.").arg(fi.baseName())); |
UBApplication::showMessage(tr("Import of file %1 failed.").arg(fi.baseName())); |
||||||
return 0; |
return 0; |
||||||
} |
} |
||||||
else{ |
else{ |
||||||
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder); |
UBDocumentProxy* newDocument = UBPersistenceManager::persistenceManager()->createDocumentFromDir(documentRootFolder, pGroup); |
||||||
UBApplication::showMessage(tr("Import successful.")); |
|
||||||
return newDocument; |
UBApplication::showMessage(tr("Import successful.")); |
||||||
} |
|
||||||
} |
return newDocument; |
||||||
|
} |
||||||
|
} |
||||||
bool UBImportDocument::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) |
|
||||||
{ |
|
||||||
QFileInfo fi(pFile); |
bool UBImportDocument::addFileToDocument(UBDocumentProxy* pDocument, const QFile& pFile) |
||||||
UBApplication::showMessage(tr("Importing file %1...").arg(fi.baseName()), true); |
{ |
||||||
|
QFileInfo fi(pFile); |
||||||
QString path = UBFileSystemUtils::createTempDir(); |
UBApplication::showMessage(tr("Importing file %1...").arg(fi.baseName()), true); |
||||||
|
|
||||||
QString documentRootFolder = expandFileToDir(pFile, path); |
QString path = UBFileSystemUtils::createTempDir(); |
||||||
|
|
||||||
UBPersistenceManager::persistenceManager()->addDirectoryContentToDocument(documentRootFolder, pDocument); |
QString documentRootFolder = expandFileToDir(pFile, path); |
||||||
|
|
||||||
UBFileSystemUtils::deleteDir(path); |
UBPersistenceManager::persistenceManager()->addDirectoryContentToDocument(documentRootFolder, pDocument); |
||||||
|
|
||||||
UBApplication::showMessage(tr("Import successful.")); |
UBFileSystemUtils::deleteDir(path); |
||||||
|
|
||||||
return true; |
UBApplication::showMessage(tr("Import successful.")); |
||||||
} |
|
||||||
|
return true; |
||||||
|
} |
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,175 +1,175 @@ |
|||||||
/*
|
/*
|
||||||
* This program is free software: you can redistribute it and/or modify |
* This program is free software: you can redistribute it and/or modify |
||||||
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
||||||
* the Free Software Foundation, either version 3 of the License, or |
* the Free Software Foundation, either version 3 of the License, or |
||||||
* (at your option) any later version. |
* (at your option) any later version. |
||||||
* |
* |
||||||
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||||
* GNU General Public License for more details. |
* GNU General Public License for more details. |
||||||
* |
* |
||||||
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/ |
*/ |
||||||
|
|
||||||
#ifndef UBPERSISTENCEMANAGER_H_ |
#ifndef UBPERSISTENCEMANAGER_H_ |
||||||
#define UBPERSISTENCEMANAGER_H_ |
#define UBPERSISTENCEMANAGER_H_ |
||||||
|
|
||||||
#include <QtCore> |
#include <QtCore> |
||||||
|
|
||||||
#include "UBSceneCache.h" |
#include "UBSceneCache.h" |
||||||
|
|
||||||
struct sTeacherBarInfos |
struct sTeacherBarInfos |
||||||
{ |
{ |
||||||
QString title; |
QString title; |
||||||
QStringList actions; |
QStringList actions; |
||||||
QStringList medias; |
QStringList medias; |
||||||
QStringList urls; |
QStringList urls; |
||||||
QString comments; |
QString comments; |
||||||
}; |
}; |
||||||
|
|
||||||
class UBDocument; |
class UBDocument; |
||||||
class UBDocumentProxy; |
class UBDocumentProxy; |
||||||
class UBGraphicsScene; |
class UBGraphicsScene; |
||||||
|
|
||||||
class UBPersistenceManager : public QObject |
class UBPersistenceManager : public QObject |
||||||
{ |
{ |
||||||
Q_OBJECT |
Q_OBJECT |
||||||
|
|
||||||
private: |
private: |
||||||
UBPersistenceManager(QObject *pParent = 0); |
UBPersistenceManager(QObject *pParent = 0); |
||||||
static UBPersistenceManager* sSingleton; |
static UBPersistenceManager* sSingleton; |
||||||
|
|
||||||
public: |
public: |
||||||
|
|
||||||
virtual ~UBPersistenceManager(); |
virtual ~UBPersistenceManager(); |
||||||
|
|
||||||
static const QString imageDirectory; |
static const QString imageDirectory; |
||||||
static const QString objectDirectory; |
static const QString objectDirectory; |
||||||
static const QString videoDirectory; |
static const QString videoDirectory; |
||||||
static const QString audioDirectory; |
static const QString audioDirectory; |
||||||
static const QString widgetDirectory; |
static const QString widgetDirectory; |
||||||
|
|
||||||
static UBPersistenceManager* persistenceManager(); |
static UBPersistenceManager* persistenceManager(); |
||||||
static void destroy(); |
static void destroy(); |
||||||
|
|
||||||
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true); |
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true); |
||||||
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory); |
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false); |
||||||
|
|
||||||
virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy); |
virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
virtual UBDocumentProxy* duplicateDocument(UBDocumentProxy* pDocumentProxy); |
virtual UBDocumentProxy* duplicateDocument(UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
virtual void deleteDocument(UBDocumentProxy* pDocumentProxy); |
virtual void deleteDocument(UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
virtual void deleteDocumentScenes(UBDocumentProxy* pDocumentProxy, const QList<int>& indexes); |
virtual void deleteDocumentScenes(UBDocumentProxy* pDocumentProxy, const QList<int>& indexes); |
||||||
|
|
||||||
virtual void duplicateDocumentScene(UBDocumentProxy* pDocumentProxy, int index); |
virtual void duplicateDocumentScene(UBDocumentProxy* pDocumentProxy, int index); |
||||||
|
|
||||||
virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy, |
virtual void persistDocumentScene(UBDocumentProxy* pDocumentProxy, |
||||||
UBGraphicsScene* pScene, const int pSceneIndex); |
UBGraphicsScene* pScene, const int pSceneIndex); |
||||||
virtual void persistTeacherBar(UBDocumentProxy* pDocumentProxy, int page, sTeacherBarInfos infos); |
virtual void persistTeacherBar(UBDocumentProxy* pDocumentProxy, int page, sTeacherBarInfos infos); |
||||||
|
|
||||||
sTeacherBarInfos getTeacherBarInfos(UBDocumentProxy* pDocumentProxy, int page); |
sTeacherBarInfos getTeacherBarInfos(UBDocumentProxy* pDocumentProxy, int page); |
||||||
|
|
||||||
virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index); |
virtual UBGraphicsScene* createDocumentSceneAt(UBDocumentProxy* pDocumentProxy, int index); |
||||||
|
|
||||||
virtual void insertDocumentSceneAt(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* scene, int index); |
virtual void insertDocumentSceneAt(UBDocumentProxy* pDocumentProxy, UBGraphicsScene* scene, int index); |
||||||
|
|
||||||
virtual void moveSceneToIndex(UBDocumentProxy* pDocumentProxy, int source, int target); |
virtual void moveSceneToIndex(UBDocumentProxy* pDocumentProxy, int source, int target); |
||||||
|
|
||||||
virtual UBGraphicsScene* loadDocumentScene(UBDocumentProxy* pDocumentProxy, int sceneIndex); |
virtual UBGraphicsScene* loadDocumentScene(UBDocumentProxy* pDocumentProxy, int sceneIndex); |
||||||
UBGraphicsScene *getDocumentScene(UBDocumentProxy* pDocumentProxy, int sceneIndex) {return mSceneCache.value(pDocumentProxy, sceneIndex);} |
UBGraphicsScene *getDocumentScene(UBDocumentProxy* pDocumentProxy, int sceneIndex) {return mSceneCache.value(pDocumentProxy, sceneIndex);} |
||||||
|
|
||||||
QList<QPointer<UBDocumentProxy> > documentProxies; |
QList<QPointer<UBDocumentProxy> > documentProxies; |
||||||
|
|
||||||
virtual QStringList allShapes(); |
virtual QStringList allShapes(); |
||||||
virtual QStringList allGips(); |
virtual QStringList allGips(); |
||||||
virtual QStringList allSounds(); |
virtual QStringList allSounds(); |
||||||
virtual QStringList allImages(const QDir& dir); |
virtual QStringList allImages(const QDir& dir); |
||||||
virtual QStringList allVideos(const QDir& dir); |
virtual QStringList allVideos(const QDir& dir); |
||||||
virtual QStringList allWidgets(const QDir& dir); |
virtual QStringList allWidgets(const QDir& dir); |
||||||
|
|
||||||
virtual QString generateUniqueDocumentPath(); |
virtual QString generateUniqueDocumentPath(); |
||||||
|
|
||||||
virtual void addDirectoryContentToDocument(const QString& documentRootFolder, UBDocumentProxy* pDocument); |
virtual void addDirectoryContentToDocument(const QString& documentRootFolder, UBDocumentProxy* pDocument); |
||||||
|
|
||||||
virtual void upgradeDocumentIfNeeded(UBDocumentProxy* pDocumentProxy); |
virtual void upgradeDocumentIfNeeded(UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
virtual void upgradeAllDocumentsIfNeeded(); |
virtual void upgradeAllDocumentsIfNeeded(); |
||||||
|
|
||||||
virtual UBDocumentProxy* documentByUuid(const QUuid& pUuid); |
virtual UBDocumentProxy* documentByUuid(const QUuid& pUuid); |
||||||
|
|
||||||
QStringList documentSubDirectories() |
QStringList documentSubDirectories() |
||||||
{ |
{ |
||||||
return mDocumentSubDirectories; |
return mDocumentSubDirectories; |
||||||
} |
} |
||||||
|
|
||||||
virtual bool isEmpty(UBDocumentProxy* pDocumentProxy); |
virtual bool isEmpty(UBDocumentProxy* pDocumentProxy); |
||||||
virtual void purgeEmptyDocuments(); |
virtual void purgeEmptyDocuments(); |
||||||
|
|
||||||
virtual QString addVideoFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); |
virtual QString addVideoFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); |
||||||
virtual QString addVideoFileToDocument(UBDocumentProxy* pDocumentProxy, QUrl sourceUrl, QByteArray pPayload, QUuid objectUuid); |
virtual QString addVideoFileToDocument(UBDocumentProxy* pDocumentProxy, QUrl sourceUrl, QByteArray pPayload, QUuid objectUuid); |
||||||
virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); |
virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); |
||||||
virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QUrl sourceUrl, QByteArray pPayload, QUuid objectUuid); |
virtual QString addAudioFileToDocument(UBDocumentProxy* pDocumentProxy, QUrl sourceUrl, QByteArray pPayload, QUuid objectUuid); |
||||||
virtual QString addPdfFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); |
virtual QString addPdfFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid); |
||||||
virtual QString addGraphicsWidgteToDocument(UBDocumentProxy *mDocumentProxy, QString path, QUuid objectUuid); |
virtual QString addGraphicsWidgteToDocument(UBDocumentProxy *mDocumentProxy, QString path, QUuid objectUuid); |
||||||
|
|
||||||
bool mayHaveVideo(UBDocumentProxy* pDocumentProxy); |
bool mayHaveVideo(UBDocumentProxy* pDocumentProxy); |
||||||
bool mayHaveAudio(UBDocumentProxy* pDocumentProxy); |
bool mayHaveAudio(UBDocumentProxy* pDocumentProxy); |
||||||
bool mayHavePDF(UBDocumentProxy* pDocumentProxy); |
bool mayHavePDF(UBDocumentProxy* pDocumentProxy); |
||||||
bool mayHaveSVGImages(UBDocumentProxy* pDocumentProxy); |
bool mayHaveSVGImages(UBDocumentProxy* pDocumentProxy); |
||||||
bool mayHaveWidget(UBDocumentProxy* pDocumentProxy); |
bool mayHaveWidget(UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
signals: |
signals: |
||||||
|
|
||||||
void proxyListChanged(); |
void proxyListChanged(); |
||||||
|
|
||||||
void documentCreated(UBDocumentProxy* pDocumentProxy); |
void documentCreated(UBDocumentProxy* pDocumentProxy); |
||||||
void documentMetadataChanged(UBDocumentProxy* pDocumentProxy); |
void documentMetadataChanged(UBDocumentProxy* pDocumentProxy); |
||||||
void documentCommitted(UBDocumentProxy* pDocumentProxy); |
void documentCommitted(UBDocumentProxy* pDocumentProxy); |
||||||
void documentWillBeDeleted(UBDocumentProxy* pDocumentProxy); |
void documentWillBeDeleted(UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
void documentSceneCreated(UBDocumentProxy* pDocumentProxy, int pIndex); |
void documentSceneCreated(UBDocumentProxy* pDocumentProxy, int pIndex); |
||||||
void documentSceneMoved(UBDocumentProxy* pDocumentProxy, int pIndex); |
void documentSceneMoved(UBDocumentProxy* pDocumentProxy, int pIndex); |
||||||
void documentSceneWillBeDeleted(UBDocumentProxy* pDocumentProxy, int pIndex); |
void documentSceneWillBeDeleted(UBDocumentProxy* pDocumentProxy, int pIndex); |
||||||
void documentSceneDeleted(UBDocumentProxy* pDocumentProxy, int pDeletedIndex); |
void documentSceneDeleted(UBDocumentProxy* pDocumentProxy, int pDeletedIndex); |
||||||
|
|
||||||
private: |
private: |
||||||
|
|
||||||
int sceneCount(const UBDocumentProxy* pDocumentProxy); |
int sceneCount(const UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
int sceneCountInDir(const QString& pPath); |
int sceneCountInDir(const QString& pPath); |
||||||
|
|
||||||
QList<QPointer<UBDocumentProxy> > allDocumentProxies(); |
QList<QPointer<UBDocumentProxy> > allDocumentProxies(); |
||||||
|
|
||||||
void renamePage(UBDocumentProxy* pDocumentProxy, |
void renamePage(UBDocumentProxy* pDocumentProxy, |
||||||
const int sourceIndex, const int targetIndex); |
const int sourceIndex, const int targetIndex); |
||||||
|
|
||||||
void copyPage(UBDocumentProxy* pDocumentProxy, |
void copyPage(UBDocumentProxy* pDocumentProxy, |
||||||
const int sourceIndex, const int targetIndex); |
const int sourceIndex, const int targetIndex); |
||||||
|
|
||||||
void generatePathIfNeeded(UBDocumentProxy* pDocumentProxy); |
void generatePathIfNeeded(UBDocumentProxy* pDocumentProxy); |
||||||
|
|
||||||
void checkIfDocumentRepositoryExists(); |
void checkIfDocumentRepositoryExists(); |
||||||
|
|
||||||
UBSceneCache mSceneCache; |
UBSceneCache mSceneCache; |
||||||
|
|
||||||
QStringList mDocumentSubDirectories; |
QStringList mDocumentSubDirectories; |
||||||
|
|
||||||
QMutex mDeletedListMutex; |
QMutex mDeletedListMutex; |
||||||
|
|
||||||
bool mHasPurgedDocuments; |
bool mHasPurgedDocuments; |
||||||
|
|
||||||
QList<UBDocumentProxy*> mDocumentCreatedDuringSession; |
QList<UBDocumentProxy*> mDocumentCreatedDuringSession; |
||||||
|
|
||||||
QString mDocumentRepositoryPath; |
QString mDocumentRepositoryPath; |
||||||
|
|
||||||
private slots: |
private slots: |
||||||
void documentRepositoryChanged(const QString& path); |
void documentRepositoryChanged(const QString& path); |
||||||
|
|
||||||
}; |
}; |
||||||
|
|
||||||
|
|
||||||
#endif /* UBPERSISTENCEMANAGER_H_ */ |
#endif /* UBPERSISTENCEMANAGER_H_ */ |
||||||
|
Loading…
Reference in new issue