diff --git a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp index 9cbe55eb..54ce6d51 100644 --- a/src/adaptors/UBMetadataDcSubsetAdaptor.cpp +++ b/src/adaptors/UBMetadataDcSubsetAdaptor.cpp @@ -125,8 +125,6 @@ void UBMetadataDcSubsetAdaptor::persist(UBDocumentProxy* proxy) // introduced in UB 4.4 xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "updated-at", UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTimeUtc())); - xmlWriter.writeTextElement(UBSettings::uniboardDocumentNamespaceUri, "page-count", QString::number(proxy->pageCount())); - xmlWriter.writeEndElement(); //dc:Description xmlWriter.writeEndElement(); //RDF @@ -226,11 +224,6 @@ QMap UBMetadataDcSubsetAdaptor::load(QString pPath) metadata.insert(UBSettings::documentUpdatedAt, xml.readElementText()); updatedAtFound = true; } - else if (xml.name() == "page-count" - && xml.namespaceUri() == UBSettings::uniboardDocumentNamespaceUri) - { - metadata.insert(UBSettings::documentPageCount, xml.readElementText()); - } metadata.insert(UBSettings::documentVersion, docVersion); } diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 8d1759f6..d9703d40 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -164,44 +164,36 @@ void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &c { QString fullPath = path.absoluteFilePath(); - QMap metadatas = UBMetadataDcSubsetAdaptor::load(fullPath); + QDir dir(fullPath); - QString docGroupName = metadatas.value(UBSettings::documentGroupName, QString()).toString(); - QString docName = metadatas.value(UBSettings::documentName, QString()).toString(); + if (dir.entryList(QDir::Files | QDir::NoDotAndDotDot).size() > 0) + { + QMap metadatas = UBMetadataDcSubsetAdaptor::load(fullPath); + QString docGroupName = metadatas.value(UBSettings::documentGroupName, QString()).toString(); + QString docName = metadatas.value(UBSettings::documentName, QString()).toString(); - if (docName.isEmpty()) { - qDebug() << "Group name and document name are empty in UBPersistenceManager::createDocumentProxiesStructure()"; - continue; - } + if (docName.isEmpty()) { + qDebug() << "Group name and document name are empty in UBPersistenceManager::createDocumentProxiesStructure()"; + continue; + } - QModelIndex parentIndex = mDocumentTreeStructureModel->goTo(docGroupName); - if (!parentIndex.isValid()) { - return; - } + QModelIndex parentIndex = mDocumentTreeStructureModel->goTo(docGroupName); + if (!parentIndex.isValid()) { + return; + } - UBDocumentProxy* docProxy = new UBDocumentProxy(fullPath, metadatas); // managed in UBDocumentTreeNode - foreach(QString key, metadatas.keys()) { - docProxy->setMetaData(key, metadatas.value(key)); - } + UBDocumentProxy* docProxy = new UBDocumentProxy(fullPath); // managed in UBDocumentTreeNode + foreach(QString key, metadatas.keys()) { + docProxy->setMetaData(key, metadatas.value(key)); + } - if (metadatas.contains(UBSettings::documentPageCount)) - { - int pageCount = metadatas.value(UBSettings::documentPageCount).toInt(); - if (pageCount == 0) - pageCount = sceneCount(docProxy); + docProxy->setPageCount(sceneCount(docProxy)); - docProxy->setPageCount(pageCount); - } - else - { - int pageCount = sceneCount(docProxy); - docProxy->setPageCount(pageCount); + if (!interactive) + mDocumentTreeStructureModel->addDocument(docProxy, parentIndex); + else + processInteractiveReplacementDialog(docProxy); } - - if (!interactive) - mDocumentTreeStructureModel->addDocument(docProxy, parentIndex); - else - processInteractiveReplacementDialog(docProxy); } } diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 23bbb069..2e3c5839 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -61,7 +61,6 @@ QString UBSettings::documentSize = QString("Size"); QString UBSettings::documentIdentifer = QString("ID"); QString UBSettings::documentVersion = QString("Version"); QString UBSettings::documentUpdatedAt = QString("UpdatedAt"); -QString UBSettings::documentPageCount = QString("PageCount"); QString UBSettings::documentDate = QString("date"); QString UBSettings::trashedDocumentGroupNamePrefix = QString("_Trash:"); diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 653eb6dc..9cba7a10 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -202,7 +202,6 @@ class UBSettings : public QObject static QString documentIdentifer; static QString documentVersion; static QString documentUpdatedAt; - static QString documentPageCount; static QString documentDate; diff --git a/src/document/UBDocumentProxy.cpp b/src/document/UBDocumentProxy.cpp index 0bf6e565..6f9aa711 100644 --- a/src/document/UBDocumentProxy.cpp +++ b/src/document/UBDocumentProxy.cpp @@ -56,6 +56,7 @@ UBDocumentProxy::UBDocumentProxy(const UBDocumentProxy &rValue) : mPageCount = rValue.mPageCount; } + UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath) : mPageCount(0) , mPageDpi(0) @@ -67,17 +68,6 @@ UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath) } -UBDocumentProxy::UBDocumentProxy(const QString& pPersistancePath, QMap metadatas) - : mPageCount(0) - , mPageDpi(0) -{ - init(); - setPersistencePath(pPersistancePath); - - mMetaDatas = metadatas; -} - - void UBDocumentProxy::init() { setMetaData(UBSettings::documentGroupName, ""); diff --git a/src/document/UBDocumentProxy.h b/src/document/UBDocumentProxy.h index dfff6908..cb507dec 100644 --- a/src/document/UBDocumentProxy.h +++ b/src/document/UBDocumentProxy.h @@ -49,7 +49,6 @@ class UBDocumentProxy : public QObject UBDocumentProxy(); UBDocumentProxy(const UBDocumentProxy &rValue); UBDocumentProxy(const QString& pPersistencePath); - UBDocumentProxy(const QString& pPersistencePath, QMap metadatas); virtual ~UBDocumentProxy();