improved behavior when replacing active document during import

preferencesAboutTextFull
Clément Fauconnier 5 years ago
parent a690a11420
commit 7b678ab7c7
  1. 22
      src/core/UBPersistenceManager.cpp

@ -188,15 +188,11 @@ void UBPersistenceManager::createDocumentProxiesStructure(const QFileInfoList &c
} }
docProxy->setPageCount(sceneCount(docProxy)); docProxy->setPageCount(sceneCount(docProxy));
bool addDoc = false;
if (!interactive) { if (!interactive)
addDoc = true;
} else if (processInteractiveReplacementDialog(docProxy) == QDialog::Accepted) {
addDoc = true;
}
if (addDoc) {
mDocumentTreeStructureModel->addDocument(docProxy, parentIndex); mDocumentTreeStructureModel->addDocument(docProxy, parentIndex);
} else
processInteractiveReplacementDialog(docProxy);
} }
} }
} }
@ -231,7 +227,9 @@ QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UB
, docList , docList
, /*UBApplication::documentController->mainWidget()*/0 , /*UBApplication::documentController->mainWidget()*/0
, Qt::Widget); , Qt::Widget);
if (replaceDialog->exec() == QDialog::Accepted) { if (replaceDialog->exec() == QDialog::Accepted)
{
mDocumentTreeStructureModel->addDocument(pProxy, parentIndex);
result = QDialog::Accepted; result = QDialog::Accepted;
QString resultName = replaceDialog->lineEditText(); QString resultName = replaceDialog->lineEditText();
int i = docList.indexOf(resultName); int i = docList.indexOf(resultName);
@ -256,8 +254,10 @@ QDialog::DialogCode UBPersistenceManager::processInteractiveReplacementDialog(UB
replaceDialog->setParent(0); replaceDialog->setParent(0);
delete replaceDialog; delete replaceDialog;
} else { } else {
mDocumentTreeStructureModel->addDocument(pProxy, parentIndex);
result = QDialog::Accepted; result = QDialog::Accepted;
} }
} }
//TODO claudio the if is an hack //TODO claudio the if is an hack
if(UBApplication::overrideCursor()) if(UBApplication::overrideCursor())
@ -452,11 +452,11 @@ UBDocumentProxy* UBPersistenceManager::createDocument(const QString& pGroupName
bool addDoc = false; bool addDoc = false;
if (!promptDialogIfExists) { if (!promptDialogIfExists) {
addDoc = true; addDoc = true;
mDocumentTreeStructureModel->addDocument(doc);
} else if (processInteractiveReplacementDialog(doc) == QDialog::Accepted) { } else if (processInteractiveReplacementDialog(doc) == QDialog::Accepted) {
addDoc = true; addDoc = true;
} }
if (addDoc) { if (addDoc) {
mDocumentTreeStructureModel->addDocument(doc);
emit proxyListChanged(); emit proxyListChanged();
} else { } else {
deleteDocument(doc); deleteDocument(doc);
@ -524,12 +524,12 @@ UBDocumentProxy* UBPersistenceManager::createDocumentFromDir(const QString& pDoc
bool addDoc = false; bool addDoc = false;
if (!promptDialogIfExists) { if (!promptDialogIfExists) {
addDoc = true; addDoc = true;
mDocumentTreeStructureModel->addDocument(doc);
} else if (processInteractiveReplacementDialog(doc) == QDialog::Accepted) { } else if (processInteractiveReplacementDialog(doc) == QDialog::Accepted) {
addDoc = true; addDoc = true;
} }
if (addDoc) { if (addDoc) {
UBMetadataDcSubsetAdaptor::persist(doc); UBMetadataDcSubsetAdaptor::persist(doc);
mDocumentTreeStructureModel->addDocument(doc);
emit proxyListChanged(); emit proxyListChanged();
emit documentCreated(doc); emit documentCreated(doc);
} else { } else {

Loading…
Cancel
Save