|
|
@ -34,6 +34,7 @@ |
|
|
|
#include <QDomDocument> |
|
|
|
#include <QDomDocument> |
|
|
|
#include <QXmlStreamWriter> |
|
|
|
#include <QXmlStreamWriter> |
|
|
|
#include <QModelIndex> |
|
|
|
#include <QModelIndex> |
|
|
|
|
|
|
|
#include <QtConcurrent> |
|
|
|
|
|
|
|
|
|
|
|
#include "frameworks/UBPlatformUtils.h" |
|
|
|
#include "frameworks/UBPlatformUtils.h" |
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
|
#include "frameworks/UBFileSystemUtils.h" |
|
|
@ -98,7 +99,6 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent) |
|
|
|
mDocumentTreeStructureModel = new UBDocumentTreeModel(this); |
|
|
|
mDocumentTreeStructureModel = new UBDocumentTreeModel(this); |
|
|
|
createDocumentProxiesStructure(); |
|
|
|
createDocumentProxiesStructure(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit proxyListChanged(); |
|
|
|
emit proxyListChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -131,7 +131,27 @@ void UBPersistenceManager::createDocumentProxiesStructure(bool interactive) |
|
|
|
rootDir.mkpath(rootDir.path()); |
|
|
|
rootDir.mkpath(rootDir.path()); |
|
|
|
|
|
|
|
|
|
|
|
QFileInfoList contentList = rootDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time | QDir::Reversed); |
|
|
|
QFileInfoList contentList = rootDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time | QDir::Reversed); |
|
|
|
createDocumentProxiesStructure(contentList, interactive); |
|
|
|
|
|
|
|
|
|
|
|
mProgress.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint); |
|
|
|
|
|
|
|
mProgress.setLabelText(QString("retrieving all your documents (found %1)").arg(contentList.size())); |
|
|
|
|
|
|
|
mProgress.setCancelButton(nullptr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create a QFutureWatcher and connect signals and slots.
|
|
|
|
|
|
|
|
QFutureWatcher<void> futureWatcher; |
|
|
|
|
|
|
|
QObject::connect(&futureWatcher, &QFutureWatcher<void>::finished, &mProgress, &QProgressDialog::reset); |
|
|
|
|
|
|
|
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressRangeChanged, &mProgress, &QProgressDialog::setRange); |
|
|
|
|
|
|
|
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &mProgress, &QProgressDialog::setValue); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start the computation.
|
|
|
|
|
|
|
|
futureWatcher.setFuture(QtConcurrent::map(contentList, [=] (QFileInfo& contentInfo) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
createDocumentProxyStructure(contentInfo); |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Display the dialog and start the event loop.
|
|
|
|
|
|
|
|
mProgress.exec(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
futureWatcher.waitForFinished(); |
|
|
|
|
|
|
|
|
|
|
|
if (QFileInfo(mFoldersXmlStorageName).exists()) { |
|
|
|
if (QFileInfo(mFoldersXmlStorageName).exists()) { |
|
|
|
QDomDocument xmlDom; |
|
|
|
QDomDocument xmlDom; |
|
|
@ -158,12 +178,17 @@ void UBPersistenceManager::createDocumentProxiesStructure(bool interactive) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &contentInfo, bool interactive) |
|
|
|
void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &contentInfoList, bool interactive) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach(QFileInfo path, contentInfo) |
|
|
|
foreach(QFileInfo contentInfo, contentInfoList) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QString fullPath = path.absoluteFilePath(); |
|
|
|
createDocumentProxyStructure(contentInfo, interactive); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBPersistenceManager::createDocumentProxyStructure(const QFileInfo &contentInfo, bool interactive) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QString fullPath = contentInfo.absoluteFilePath(); |
|
|
|
QDir dir(fullPath); |
|
|
|
QDir dir(fullPath); |
|
|
|
|
|
|
|
|
|
|
|
if (dir.entryList(QDir::Files | QDir::NoDotAndDotDot).size() > 0) |
|
|
|
if (dir.entryList(QDir::Files | QDir::NoDotAndDotDot).size() > 0) |
|
|
@ -174,7 +199,7 @@ void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &c |
|
|
|
|
|
|
|
|
|
|
|
if (docName.isEmpty()) { |
|
|
|
if (docName.isEmpty()) { |
|
|
|
qDebug() << "Group name and document name are empty in UBPersistenceManager::createDocumentProxiesStructure()"; |
|
|
|
qDebug() << "Group name and document name are empty in UBPersistenceManager::createDocumentProxiesStructure()"; |
|
|
|
continue; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QModelIndex parentIndex = mDocumentTreeStructureModel->goTo(docGroupName); |
|
|
|
QModelIndex parentIndex = mDocumentTreeStructureModel->goTo(docGroupName); |
|
|
@ -194,8 +219,7 @@ void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &c |
|
|
|
else |
|
|
|
else |
|
|
|
processInteractiveReplacementDialog(docProxy); |
|
|
|
processInteractiveReplacementDialog(docProxy); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UBDocumentProxy *pProxy) |
|
|
|
QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UBDocumentProxy *pProxy) |
|
|
|
{ |
|
|
|
{ |
|
|
|