cherry-picked 670d772 + b944207c

preferencesAboutTextFull
Clément Fauconnier 3 years ago
parent e5b7251fd1
commit b943a0d79d
  1. 89
      src/core/UBPersistenceManager.cpp
  2. 2
      src/core/UBPersistenceManager.h
  3. 2
      src/document/UBDocumentController.cpp
  4. 4
      src/gui/UBBoardThumbnailsView.cpp

@ -123,36 +123,65 @@ UBPersistenceManager::~UBPersistenceManager()
{ {
} }
void UBPersistenceManager::createDocumentProxiesStructure(bool interactive) void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &contentInfoList, bool interactive)
{ {
mDocumentRepositoryPath = UBSettings::userDocumentDirectory();
QDir rootDir(mDocumentRepositoryPath);
rootDir.mkpath(rootDir.path());
QFileInfoList contentList = rootDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time | QDir::Reversed);
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. // Create a QFutureWatcher and connect signals and slots.
QFutureWatcher<void> futureWatcher; QFutureWatcher<UBDocumentProxy*> futureWatcher;
QObject::connect(&futureWatcher, &QFutureWatcher<void>::finished, &mProgress, &QProgressDialog::reset); QObject::connect(&futureWatcher, &QFutureWatcher<void>::finished, &mProgress, &QProgressDialog::reset);
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressRangeChanged, &mProgress, &QProgressDialog::setRange); QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressRangeChanged, &mProgress, &QProgressDialog::setRange);
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &mProgress, &QProgressDialog::setValue); QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &mProgress, &QProgressDialog::setValue);
// Start the computation. // Start the computation.
futureWatcher.setFuture(QtConcurrent::map(contentList, [=] (QFileInfo& contentInfo) std::function<UBDocumentProxy* (QFileInfo contentInfo)> createDocumentProxyLambda = [=](QFileInfo contentInfo) {
{ return createDocumentProxyStructure(contentInfo);
createDocumentProxyStructure(contentInfo); };
}));
QFuture<UBDocumentProxy*> proxiesFuture = QtConcurrent::mapped(contentInfoList, createDocumentProxyLambda);
futureWatcher.setFuture(proxiesFuture);
// Display the dialog and start the event loop. // Display the dialog and start the event loop.
mProgress.exec(); mProgress.exec();
futureWatcher.waitForFinished(); futureWatcher.waitForFinished();
QList<UBDocumentProxy*> proxies = futureWatcher.future().results();
for (auto&& proxy : qAsConst(proxies))
{
if (proxy)
{
QString docGroupName = proxy->metaData(UBSettings::documentGroupName).toString();
QModelIndex parentIndex = mDocumentTreeStructureModel->goTo(docGroupName);
if (parentIndex.isValid())
{
if (!interactive)
mDocumentTreeStructureModel->addDocument(proxy, parentIndex);
else
processInteractiveReplacementDialog(proxy);
}
else
{
qDebug() << "something went wrong";
}
}
}
}
void UBPersistenceManager::createDocumentProxiesStructure(bool interactive)
{
mDocumentRepositoryPath = UBSettings::userDocumentDirectory();
QDir rootDir(mDocumentRepositoryPath);
rootDir.mkpath(rootDir.path());
QFileInfoList contentInfoList = rootDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time | QDir::Reversed);
mProgress.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
mProgress.setLabelText(QString("retrieving all your documents (found %1)").arg(contentInfoList.size()));
mProgress.setCancelButton(nullptr);
createDocumentProxiesStructure(contentInfoList, interactive);
if (QFileInfo(mFoldersXmlStorageName).exists()) { if (QFileInfo(mFoldersXmlStorageName).exists()) {
QDomDocument xmlDom; QDomDocument xmlDom;
QFile inFile(mFoldersXmlStorageName); QFile inFile(mFoldersXmlStorageName);
@ -178,15 +207,7 @@ void UBPersistenceManager::createDocumentProxiesStructure(bool interactive)
} }
} }
void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &contentInfoList, bool interactive) UBDocumentProxy* UBPersistenceManager::createDocumentProxyStructure(QFileInfo& contentInfo)
{
foreach(QFileInfo contentInfo, contentInfoList)
{
createDocumentProxyStructure(contentInfo, interactive);
}
}
void UBPersistenceManager::createDocumentProxyStructure(const QFileInfo &contentInfo, bool interactive)
{ {
QString fullPath = contentInfo.absoluteFilePath(); QString fullPath = contentInfo.absoluteFilePath();
QDir dir(fullPath); QDir dir(fullPath);
@ -199,12 +220,7 @@ void UBPersistenceManager::createDocumentProxyStructure(const QFileInfo &content
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()";
return; return nullptr;
}
QModelIndex parentIndex = mDocumentTreeStructureModel->goTo(docGroupName);
if (!parentIndex.isValid()) {
return;
} }
UBDocumentProxy* docProxy = new UBDocumentProxy(fullPath); // managed in UBDocumentTreeNode UBDocumentProxy* docProxy = new UBDocumentProxy(fullPath); // managed in UBDocumentTreeNode
@ -214,11 +230,12 @@ void UBPersistenceManager::createDocumentProxyStructure(const QFileInfo &content
docProxy->setPageCount(sceneCount(docProxy)); docProxy->setPageCount(sceneCount(docProxy));
if (!interactive) docProxy->moveToThread(UBApplication::instance()->thread());
mDocumentTreeStructureModel->addDocument(docProxy, parentIndex);
else return docProxy;
processInteractiveReplacementDialog(docProxy);
} }
return nullptr;
}; };
QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UBDocumentProxy *pProxy) QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UBDocumentProxy *pProxy)

@ -132,7 +132,7 @@ class UBPersistenceManager : public QObject
void createDocumentProxiesStructure(bool interactive = false); void createDocumentProxiesStructure(bool interactive = false);
void createDocumentProxiesStructure(const QFileInfoList &contentInfoList, bool interactive = false); void createDocumentProxiesStructure(const QFileInfoList &contentInfoList, bool interactive = false);
void createDocumentProxyStructure(const QFileInfo& contentInfo, bool interactive = false); UBDocumentProxy* createDocumentProxyStructure(QFileInfo &contentInfo);
QDialog::DialogCode processInteractiveReplacementDialog(UBDocumentProxy *pProxy); QDialog::DialogCode processInteractiveReplacementDialog(UBDocumentProxy *pProxy);
QStringList documentSubDirectories() QStringList documentSubDirectories()

@ -3781,6 +3781,8 @@ void UBDocumentController:: refreshDocumentThumbnailsView(UBDocumentContainer* s
, QList<QUrl>() , QList<QUrl>()
, QStringList() , QStringList()
, UBApplication::mimeTypeUniboardPage); , UBApplication::mimeTypeUniboardPage);
QApplication::restoreOverrideCursor();
return; return;
} }

@ -307,7 +307,7 @@ void UBBoardThumbnailsView::dragMoveEvent(QDragMoveEvent *event)
{ {
y = item->pos().y() - UBSettings::thumbnailSpacing / 2; y = item->pos().y() - UBSettings::thumbnailSpacing / 2;
if (mDropBar->y() != y) if (mDropBar->y() != y)
mDropBar->setRect(QRectF(item->pos().x(), y, mThumbnailWidth-verticalScrollBar()->width(), 3)); mDropBar->setRect(QRectF(item->pos().x(), y, (item->boundingRect().width()-verticalScrollBar()->width())*scale, 3));
} }
} }
else else
@ -316,7 +316,7 @@ void UBBoardThumbnailsView::dragMoveEvent(QDragMoveEvent *event)
{ {
y = item->pos().y() + item->boundingRect().height() * scale + UBSettings::thumbnailSpacing / 2; y = item->pos().y() + item->boundingRect().height() * scale + UBSettings::thumbnailSpacing / 2;
if (mDropBar->y() != y) if (mDropBar->y() != y)
mDropBar->setRect(QRectF(item->pos().x(), y, mThumbnailWidth-verticalScrollBar()->width(), 3)); mDropBar->setRect(QRectF(item->pos().x(), y, (item->boundingRect().width()-verticalScrollBar()->width())*scale, 3));
} }
} }
} }

Loading…
Cancel
Save