Merge branch 'craig-dev' into dev

Merging of the new settings and metadata saving feature into the main
development branch
preferencesAboutTextFull
Craig Watson 9 years ago
commit 7ca7dd2c87
  1. 2
      src/adaptors/UBMetadataDcSubsetAdaptor.cpp
  2. 3
      src/board/UBBoardController.cpp
  3. 71
      src/core/UBPersistenceManager.cpp
  4. 3
      src/core/UBPersistenceManager.h
  5. 16
      src/core/UBPersistenceWorker.cpp
  6. 5
      src/core/UBPersistenceWorker.h
  7. 5
      src/core/UBSetting.h
  8. 160
      src/core/UBSettings.cpp
  9. 9
      src/core/UBSettings.h
  10. 15
      src/document/UBDocumentController.cpp
  11. 19
      src/document/UBDocumentProxy.cpp
  12. 6
      src/document/UBDocumentProxy.h

@ -86,7 +86,7 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy)
return;
}
QString fileName = proxy->persistencePath() + "/" + metadataFilename;
qWarning() << "Persisting document path is" << fileName;
qWarning() << "Persisting document; path is" << fileName;
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{

@ -1552,7 +1552,7 @@ void UBBoardController::moveSceneToIndex(int source, int target)
UBDocumentContainer::movePageToIndex(source, target);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(selectedDocument());
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(selectedDocument());
mMovingSceneIndex = source;
setActiveDocumentScene(target);
mMovingSceneIndex = -1;
@ -1777,6 +1777,7 @@ void UBBoardController::autosaveTimeout()
}
saveData(sf_showProgress);
UBSettings::settings()->save();
}
void UBBoardController::appMainModeChanged(UBApplicationController::MainMode md)

@ -79,14 +79,33 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent)
mThread = new QThread;
mWorker = new UBPersistenceWorker();
mWorker->moveToThread(mThread);
connect(mWorker, SIGNAL(error(QString)), this, SLOT(errorString(QString)));
connect(mThread, SIGNAL(started()), mWorker, SLOT(process()));
connect(mWorker, SIGNAL(finished()), mThread, SLOT(quit()));
connect(mWorker, SIGNAL(finished()), this, SLOT(onWorkerFinished()));
connect(mWorker, SIGNAL(finished()), mWorker, SLOT(deleteLater()));
connect(mThread, SIGNAL(finished()), mThread, SLOT(deleteLater()));
connect(mWorker,SIGNAL(sceneLoaded(QByteArray,UBDocumentProxy*,int)),this,SLOT(onSceneLoaded(QByteArray,UBDocumentProxy*,int)));
connect(mWorker,SIGNAL(scenePersisted(UBGraphicsScene*)),this,SLOT(onScenePersisted(UBGraphicsScene*)));
connect(mWorker, SIGNAL(error(QString)),
this, SLOT(errorString(QString)));
connect(mThread, SIGNAL(started()),
mWorker, SLOT(process()));
connect(mWorker, SIGNAL(finished()),
mThread, SLOT(quit()));
connect(mWorker, SIGNAL(finished()),
this, SLOT(onWorkerFinished()));
connect(mWorker, SIGNAL(finished()),
mWorker, SLOT(deleteLater()));
connect(mThread, SIGNAL(finished()),
mThread, SLOT(deleteLater()));
connect(mWorker, SIGNAL(sceneLoaded(QByteArray,UBDocumentProxy*,int)),
this, SLOT(onSceneLoaded(QByteArray,UBDocumentProxy*,int)));
connect(mWorker, SIGNAL(scenePersisted(UBGraphicsScene*)),
this, SLOT(onScenePersisted(UBGraphicsScene*)));
connect(mWorker, SIGNAL(metadataPersisted(UBDocumentProxy*)),
this, SLOT(onMetadataPersisted(UBDocumentProxy*)));
mThread->start();
}
@ -114,6 +133,11 @@ void UBPersistenceManager::onScenePersisted(UBGraphicsScene* scene)
scene = NULL;
}
void UBPersistenceManager::onMetadataPersisted(UBDocumentProxy* proxy)
{
delete proxy;
}
void UBPersistenceManager::onWorkerFinished()
{
mIsWorkerFinished = true;
@ -187,13 +211,6 @@ QList<QPointer<UBDocumentProxy> > UBPersistenceManager::allDocumentProxies()
{
UBDocumentProxy* proxy = new UBDocumentProxy(fullPath); // deleted in UBPersistenceManager::destructor
QMap<QString, QVariant> metadatas = UBMetadataDcSubsetAdaptor::load(fullPath);
foreach(QString key, metadatas.keys())
{
proxy->setMetaData(key, metadatas.value(key));
}
proxy->setPageCount(sceneCount(proxy));
proxies << QPointer<UBDocumentProxy>(proxy);
@ -352,13 +369,6 @@ UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDoc
doc->setMetaData(UBSettings::documentName, pName);
}
QMap<QString, QVariant> metadatas = UBMetadataDcSubsetAdaptor::load(pDocumentDirectory);
foreach(QString key, metadatas.keys())
{
doc->setMetaData(key, metadatas.value(key));
}
doc->setUuid(QUuid::createUuid());
doc->setPageCount(sceneCount(doc));
@ -751,11 +761,12 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
mSceneCache.insert(pDocumentProxy, pSceneIndex, pScene);
if (pDocumentProxy->isModified())
UBMetadataDcSubsetAdaptor::persist(pDocumentProxy);
if (pScene->isModified())
{
//qDebug() << "Persisting scene";
if (pDocumentProxy->isModified())
persistDocumentMetadata(pDocumentProxy, forceImmediateSaving);
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
if(forceImmediateSaving)
UBSvgSubsetAdaptor::persistScene(pDocumentProxy,pScene,pSceneIndex);
@ -769,13 +780,17 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
}
UBDocumentProxy* UBPersistenceManager::persistDocumentMetadata(UBDocumentProxy* pDocumentProxy)
void UBPersistenceManager::persistDocumentMetadata(UBDocumentProxy* pDocumentProxy, bool forceImmediateSaving)
{
if (forceImmediateSaving) {
UBMetadataDcSubsetAdaptor::persist(pDocumentProxy);
emit documentMetadataChanged(pDocumentProxy);
}
return pDocumentProxy;
else {
UBDocumentProxy* copy = pDocumentProxy->deepCopy();
mWorker->saveMetadata(copy);
}
}

@ -64,7 +64,7 @@ class UBPersistenceManager : public QObject
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true);
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "");
virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy);
virtual void persistDocumentMetadata(UBDocumentProxy* pDocumentProxy, bool forceImmediateSaving = false);
virtual UBDocumentProxy* duplicateDocument(UBDocumentProxy* pDocumentProxy);
@ -161,6 +161,7 @@ class UBPersistenceManager : public QObject
void onSceneLoaded(QByteArray,UBDocumentProxy*,int);
void onWorkerFinished();
void onScenePersisted(UBGraphicsScene* scene);
void onMetadataPersisted(UBDocumentProxy* proxy);
};

@ -25,6 +25,7 @@
#include "UBPersistenceWorker.h"
#include "adaptors/UBSvgSubsetAdaptor.h"
#include "adaptors/UBThumbnailAdaptor.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.h"
UBPersistenceWorker::UBPersistenceWorker(QObject *parent) :
QObject(parent)
@ -48,6 +49,13 @@ void UBPersistenceWorker::readScene(UBDocumentProxy* proxy, const int pageIndex)
mSemaphore.release();
}
void UBPersistenceWorker::saveMetadata(UBDocumentProxy *proxy)
{
PersistenceInformation entry = {WriteMetadata, proxy, NULL, 0};
saves.append(entry);
mSemaphore.release();
}
void UBPersistenceWorker::applicationWillClose()
{
qDebug() << "applicaiton Will close signal received";
@ -65,9 +73,15 @@ void UBPersistenceWorker::process()
UBSvgSubsetAdaptor::persistScene(info.proxy, info.scene, info.sceneIndex);
emit scenePersisted(info.scene);
}
else{
else if (info.action == ReadScene){
emit sceneLoaded(UBSvgSubsetAdaptor::loadSceneAsText(info.proxy,info.sceneIndex), info.proxy, info.sceneIndex);
}
else if (info.action == WriteMetadata) {
if (info.proxy->isModified()) {
UBMetadataDcSubsetAdaptor::persist(info.proxy);
emit metadataPersisted(info.proxy);
}
}
mSemaphore.acquire();
}while(!mReceivedApplicationClosing);
qDebug() << "process will stop";

@ -32,7 +32,8 @@
typedef enum{
WriteScene = 0,
ReadScene
ReadScene,
WriteMetadata
}ActionType;
typedef struct{
@ -50,12 +51,14 @@ public:
void saveScene(UBDocumentProxy* proxy, UBGraphicsScene* scene, const int pageIndex);
void readScene(UBDocumentProxy* proxy, const int pageIndex);
void saveMetadata(UBDocumentProxy* proxy);
signals:
void finished();
void error(QString string);
void sceneLoaded(QByteArray text,UBDocumentProxy* proxy, const int pageIndex);
void scenePersisted(UBGraphicsScene* scene);
void metadataPersisted(UBDocumentProxy* proxy);
public slots:
void process();

@ -62,6 +62,11 @@ class UBSetting : public QObject
return mPath;
}
virtual QVariant defaultValue() const
{
return mDefaultValue;
}
public slots:
void setBool(bool pValue);

@ -118,8 +118,10 @@ QString UBSettings::appPingMessage = "__uniboard_ping";
UBSettings* UBSettings::settings()
{
if (!sSingleton)
if (!sSingleton) {
sSingleton = new UBSettings(qApp);
sSingleton->load();
}
return sSingleton;
}
@ -146,9 +148,10 @@ QSettings* UBSettings::getAppSettings()
UBSettings::sAppSettings = new QSettings(appSettings, QSettings::IniFormat, 0);
UBSettings::sAppSettings->setIniCodec("utf-8");
qDebug() << "sAppSettings location: " << appSettings;
}
qDebug() << "sAppSettings" << sAppSettings;
return UBSettings::sAppSettings;
}
@ -223,13 +226,13 @@ void UBSettings::init()
appPreferredLanguage = new UBSetting(this,"App","PreferredLanguage", "");
rightLibPaletteBoardModeWidth = new UBSetting(this, "Board", "RightLibPaletteBoardModeWidth", 270);
rightLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteBoardModeIsCollapsed",false);
rightLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteBoardModeIsCollapsed",true);
rightLibPaletteDesktopModeWidth = new UBSetting(this, "Board", "RightLibPaletteDesktopModeWidth", 270);
rightLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteDesktopModeIsCollapsed",false);
rightLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board", "RightLibPaletteDesktopModeIsCollapsed",true);
leftLibPaletteBoardModeWidth = new UBSetting(this, "Board", "LeftLibPaletteBoardModeWidth",270);
leftLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteBoardModeIsCollapsed",false);
leftLibPaletteBoardModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteBoardModeIsCollapsed",true);
leftLibPaletteDesktopModeWidth = new UBSetting(this, "Board", "LeftLibPaletteDesktopModeWidth",270);
leftLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteDesktopModeIsCollapsed",false);
leftLibPaletteDesktopModeIsCollapsed = new UBSetting(this,"Board","LeftLibPaletteDesktopModeIsCollapsed",true);
appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false);
appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", "");
@ -265,11 +268,11 @@ void UBSettings::init()
pageDpi = new UBSetting(this, "Board", "pageDpi", 0);
QStringList penLightBackgroundColors;
penLightBackgroundColors << "#000000" << "#FF0000" <<"#004080" << "#008000" << "#FFDD00" << "#C87400" << "#800040" << "#008080" << "#5F2D0A";
penLightBackgroundColors << "#000000" << "#FF0000" <<"#004080" << "#008000" << "#FFDD00" << "#C87400" << "#800040" << "#008080" << "#5F2D0A" << "#FFFFFF";
boardPenLightBackgroundColors = new UBColorListSetting(this, "Board", "PenLightBackgroundColors", penLightBackgroundColors, 1.0);
QStringList penDarkBackgroundColors;
penDarkBackgroundColors << "#FFFFFF" << "#FF3400" <<"#66C0FF" << "#81FF5C" << "#FFFF00" << "#B68360" << "#FF497E" << "#8D69FF";
penDarkBackgroundColors << "#FFFFFF" << "#FF3400" <<"#66C0FF" << "#81FF5C" << "#FFFF00" << "#B68360" << "#FF497E" << "#8D69FF" << "#000000";
boardPenDarkBackgroundColors = new UBColorListSetting(this, "Board", "PenDarkBackgroundColors", penDarkBackgroundColors, 1.0);
boardMarkerAlpha = new UBSetting(this, "Board", "MarkerAlpha", 0.5);
@ -418,25 +421,82 @@ void UBSettings::init()
useSystemOnScreenKeyboard = new UBSetting(this, "App", "UseSystemOnScreenKeyboard", true);
cleanNonPersistentSettings();
checkNewSettings();
}
QVariant UBSettings::value ( const QString & key, const QVariant & defaultValue) const
/**
* @brief Returns the value for the *key* setting, or *defaultValue* if the key doesn't exist
*
* The value is also added to the local settings queue, to prevent future disk I/O when accessing
* that same setting.
*
* If the value doesn't exist in the application settings (i.e it was not present in the config file),
* it is also added there.
*/
QVariant UBSettings::value ( const QString & key, const QVariant & defaultValue)
{
// Check first the settings queue, then the app settings, then the user settings.
// If the key exists in neither of these, then defaultValue is returned.
if (mSettingsQueue.contains(key))
return mSettingsQueue.value(key);
// If the setting doesn't exist in the App settings, add it there
if (!sAppSettings->contains(key) && !(defaultValue == QVariant()))
{
sAppSettings->setValue(key, defaultValue);
}
return mUserSettings->value(key, sAppSettings->value(key, defaultValue));
QVariant val = mUserSettings->value(key, sAppSettings->value(key, defaultValue));
// If we got here, then the settings queue doesn't contain the value; add it
mSettingsQueue[key] = val;
return val;
}
void UBSettings::setValue (const QString & key, const QVariant & value)
{
mUserSettings->setValue(key, value);
// Save the setting to the queue only; a call to save() is necessary to persist the settings
mSettingsQueue[key] = value;
}
/**
* @brief Save all the queued settings to disk
*/
void UBSettings::save()
{
QHash<QString, QVariant>::const_iterator it = mSettingsQueue.constBegin();
while (it != mSettingsQueue.constEnd()) {
mUserSettings->setValue(it.key(), it.value());
++it;
}
// Force save to file
mUserSettings->sync();
qDebug() << "User settings saved";
}
/**
* @brief Force load all settings, to cut down on subsequent file access
*/
void UBSettings::load()
{
qDebug() << "Loading all settings";
QStringList keyList = mUserSettings->allKeys() + sAppSettings->allKeys();
keyList.removeDuplicates();
foreach(const QString& key, keyList) {
value(key);
// value() actually handles saving the value to the queue, so
// we don't need to do it here
}
}
int UBSettings::penWidthIndex()
{
@ -1264,6 +1324,7 @@ QString UBSettings::replaceWildcard(QString& path)
void UBSettings::closing()
{
save();
cleanNonPersistentSettings();
}
@ -1279,3 +1340,76 @@ void UBSettings::cleanNonPersistentSettings()
youTubeUserEMail->set(QVariant(""));
}
}
/**
* @brief Permanently remove a setting, from local memory and config files
* @param setting The setting to remove
*/
void UBSettings::removeSetting(const QString &setting)
{
if (sAppSettings->contains(setting))
sAppSettings->remove(setting);
if (mUserSettings->contains(setting))
mUserSettings->remove(setting);
if (mSettingsQueue.contains(setting))
mSettingsQueue.remove(setting);
}
void UBSettings::checkNewSettings()
{
/*
* Some settings were modified in new versions and OpenBoard can crash
* if an old settings file is used. This function checks these settings and
* if necessary, resets them to the values initialized in UBSettings::init().
*
* Thus this method can be removed when it is no longer deemed useful.
*/
// OB 1.10 introduced an extra pen color; for simplicity, if the old settings
// are still present (i.e only 4 selected pen colors), we just reset all color settings.
// Having too few colors actually causes OpenBoard to crash, hence these measures.
QList<UBColorListSetting*> colorSettings;
colorSettings << boardPenDarkBackgroundSelectedColors
<< boardPenLightBackgroundSelectedColors
<< boardMarkerDarkBackgroundSelectedColors
<< boardMarkerLightBackgroundSelectedColors;
foreach (UBColorListSetting* setting, colorSettings) {
if (setting->colors().size() < 5)
setting->reset(); // Make sure that there are 5 selected colors
}
colorSettings.clear();
// Next we check whether all the new colors were added; i.e if some default
// colors are not also in the config file, we add them to it.
// This is not nearly as critical as the above issue, but the users (or admins) seemingly
// can't be trusted to delete or modify their own config file when upgrading, so they might
// wonder why they don't have the new colors in their app.
colorSettings << boardPenDarkBackgroundColors
<< boardPenLightBackgroundColors
<< boardMarkerDarkBackgroundColors
<< boardMarkerLightBackgroundColors;
foreach (UBColorListSetting* setting, colorSettings) {
QStringList defaultColors = qvariant_cast<QStringList>(setting->defaultValue());
QStringList currentColors(qvariant_cast<QStringList>(setting->get())); // copy
foreach (QString c, defaultColors) {
if (!currentColors.contains(c))
currentColors.append(QString(c));
}
setting->set(currentColors);
}
// A typo was corrected in version 1.10
removeSetting("Board/useSystemOnScreenKeybard");
}

@ -57,6 +57,8 @@ class UBSettings : public QObject
void InitKeyboardPaletteKeyBtnSizes();
void ValidateKeyboardPaletteKeyBtnSize();
void closing();
void save();
void load();
int penWidthIndex();
@ -397,7 +399,7 @@ class UBSettings : public QObject
void setPenPressureSensitive(bool sensitive);
void setMarkerPressureSensitive(bool sensitive);
QVariant value ( const QString & key, const QVariant & defaultValue = QVariant() ) const;
QVariant value ( const QString & key, const QVariant & defaultValue = QVariant() );
void setValue (const QString & key,const QVariant & value);
void colorChanged() { emit colorContextChanged(); }
@ -410,6 +412,8 @@ class UBSettings : public QObject
QSettings* mAppSettings;
QSettings* mUserSettings;
QHash<QString, QVariant> mSettingsQueue;
static const int sDefaultFontPixelSize;
static const char *sDefaultFontFamily;
@ -421,6 +425,9 @@ class UBSettings : public QObject
static bool checkDirectory(QString& dirPath);
static QString replaceWildcard(QString& path);
void removeSetting(const QString& setting);
void checkNewSettings();
};

@ -517,7 +517,6 @@ void UBDocumentController::duplicateSelectedItem()
duplicatePages(selectedSceneIndexes);
emit documentThumbnailsUpdated(this);
selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(selectedDocument());
mDocumentUI->thumbnailWidget->selectItemAt(selectedSceneIndexes.last() + selectedSceneIndexes.size());
}
}
@ -534,7 +533,6 @@ void UBDocumentController::duplicateSelectedItem()
UBDocumentProxy* duplicatedDoc = UBPersistenceManager::persistenceManager()->duplicateDocument(source);
duplicatedDoc->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(duplicatedDoc);
selectDocument(duplicatedDoc, false);
@ -995,13 +993,7 @@ void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column)
, this, SLOT(updateDocumentInTree(UBDocumentProxy*)));
if (proxyItem)
{
if (proxyItem->proxy()->metaData(UBSettings::documentName).toString() != item->text(column))
{
proxyItem->proxy()->setMetaData(UBSettings::documentName, item->text(column));
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyItem->proxy());
}
}
else
{
// it is a group
@ -1017,7 +1009,6 @@ void UBDocumentController::itemChanged(QTreeWidgetItem * item, int column)
if (0 != (item->flags() & Qt::ItemIsEditable))
{
childItem->proxy()->setMetaData(UBSettings::documentGroupName, item->text(column));
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(childItem->proxy());
}
}
}
@ -1104,7 +1095,6 @@ void UBDocumentController::addFolderOfImages()
else
{
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document);
reloadThumbnails();
}
}
@ -1150,7 +1140,6 @@ bool UBDocumentController::addFileToDocument(UBDocumentProxy* document)
if (success)
{
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document);
}
else
{
@ -1169,7 +1158,6 @@ void UBDocumentController::moveSceneToIndex(UBDocumentProxy* proxy, int source,
if (UBDocumentContainer::movePageToIndex(source, target))
{
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy);
mDocumentUI->thumbnailWidget->hightlightItem(target);
}
@ -1497,7 +1485,6 @@ void UBDocumentController::addToDocument()
mDocumentUI->thumbnailWidget->selectItemAt(newActiveSceneIndex, false);
selectDocument(mBoardController->selectedDocument());
mBoardController->selectedDocument()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(mBoardController->selectedDocument());
UBApplication::applicationController->showBoard();
}
@ -1678,7 +1665,6 @@ void UBDocumentController::addImages()
else
{
document->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(document);
reloadThumbnails();
}
}
@ -1791,7 +1777,6 @@ void UBDocumentController::deletePages(QList<QGraphicsItem *> itemsToDelete)
UBDocumentContainer::deletePages(sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
UBMetadataDcSubsetAdaptor::persist(proxy);
int minIndex = proxy->pageCount() - 1;
foreach (int i, sceneIndexes)

@ -33,9 +33,10 @@
#include "core/UBPersistenceManager.h"
#include "core/UBSettings.h"
#include "core/UBDocumentManager.h"
#include "core/memcheck.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.h"
UBDocumentProxy::UBDocumentProxy()
: mPageCount(0)
{
@ -48,6 +49,8 @@ UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath)
{
init();
setPersistencePath(pPersistancePath);
mMetaDatas = UBMetadataDcSubsetAdaptor::load(pPersistancePath);
}
@ -69,6 +72,18 @@ UBDocumentProxy::~UBDocumentProxy()
// NOOP
}
UBDocumentProxy* UBDocumentProxy::deepCopy() const
{
UBDocumentProxy* copy = new UBDocumentProxy();
copy->mPersistencePath = QString(mPersistencePath);
copy->mMetaDatas = QMap<QString, QVariant>(mMetaDatas);
copy->mIsModified = mIsModified;
copy->mPageCount = mPageCount;
return copy;
}
int UBDocumentProxy::pageCount()
{
@ -154,7 +169,7 @@ QVariant UBDocumentProxy::metaData(const QString& pKey) const
}
}
QHash<QString, QVariant> UBDocumentProxy::metaDatas() const
QMap<QString, QVariant> UBDocumentProxy::metaDatas() const
{
return mMetaDatas;
}

@ -49,13 +49,15 @@ class UBDocumentProxy : public QObject
virtual ~UBDocumentProxy();
UBDocumentProxy * deepCopy() const;
QString persistencePath() const;
void setPersistencePath(const QString& pPersistencePath);
void setMetaData(const QString& pKey , const QVariant& pValue);
QVariant metaData(const QString& pKey) const;
QHash<QString, QVariant> metaDatas() const;
QMap<QString, QVariant> metaDatas() const;
QString name() const;
QString groupName() const;
@ -86,7 +88,7 @@ class UBDocumentProxy : public QObject
QString mPersistencePath;
QHash<QString, QVariant> mMetaDatas;
QMap<QString, QVariant> mMetaDatas;
bool mIsModified;

Loading…
Cancel
Save