|
|
@ -762,6 +762,31 @@ bool UBDocumentTreeModel::removeRows(int row, int count, const QModelIndex &pare |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool UBDocumentTreeModel::containsDocuments(const QModelIndex &index) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i = 0; i < rowCount(index); i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QModelIndex child = this->index(i, 0, index); |
|
|
|
|
|
|
|
if (isCatalog(child)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (containsDocuments(child)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (isDocument(child)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
qDebug() << "Who the hell are you ?"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QModelIndex UBDocumentTreeModel::indexForNode(UBDocumentTreeNode *pNode) const |
|
|
|
QModelIndex UBDocumentTreeModel::indexForNode(UBDocumentTreeNode *pNode) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (pNode == 0) { |
|
|
|
if (pNode == 0) { |
|
|
@ -917,7 +942,6 @@ void UBDocumentTreeModel::moveIndexes(const QModelIndexList &source, const QMode |
|
|
|
fixNodeName(s, destinationParent); |
|
|
|
fixNodeName(s, destinationParent); |
|
|
|
sourceNode->parentNode()->moveChild(sourceNode, destIndex, newParentNode); |
|
|
|
sourceNode->parentNode()->moveChild(sourceNode, destIndex, newParentNode); |
|
|
|
updateIndexNameBindings(sourceNode); |
|
|
|
updateIndexNameBindings(sourceNode); |
|
|
|
|
|
|
|
|
|
|
|
hasOneInsertion = true; |
|
|
|
hasOneInsertion = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1199,6 +1223,7 @@ void UBDocumentTreeModel::updateIndexNameBindings(UBDocumentTreeNode *nd) |
|
|
|
} else if (nd->proxyData()) { |
|
|
|
} else if (nd->proxyData()) { |
|
|
|
nd->proxyData()->setMetaData(UBSettings::documentGroupName, virtualPathForIndex(indexForNode(nd->parentNode()))); |
|
|
|
nd->proxyData()->setMetaData(UBSettings::documentGroupName, virtualPathForIndex(indexForNode(nd->parentNode()))); |
|
|
|
nd->proxyData()->setMetaData(UBSettings::documentName, nd->nodeName()); |
|
|
|
nd->proxyData()->setMetaData(UBSettings::documentName, nd->nodeName()); |
|
|
|
|
|
|
|
nd->proxyData()->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); |
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(nd->proxyData()); |
|
|
|
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(nd->proxyData()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2054,7 +2079,6 @@ void UBDocumentController::setupViews() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//N/C - NNE - 20140403
|
|
|
|
|
|
|
|
void UBDocumentController::refreshDateColumns() |
|
|
|
void UBDocumentController::refreshDateColumns() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (UBSettings::settings()->documentSortKind->get().toInt() == UBDocumentController::Alphabetical) |
|
|
|
if (UBSettings::settings()->documentSortKind->get().toInt() == UBDocumentController::Alphabetical) |
|
|
@ -2602,6 +2626,69 @@ void UBDocumentController::moveToTrash(QModelIndex &index, UBDocumentTreeModel* |
|
|
|
} |
|
|
|
} |
|
|
|
//issue 1629 - NNE - 20131212 : END
|
|
|
|
//issue 1629 - NNE - 20131212 : END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::deleteDocumentsInFolderOlderThan(const QModelIndex &index, const int days) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndexList list; |
|
|
|
|
|
|
|
for (int i = 0; i < docModel->rowCount(index); i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
list << docModel->index(i, 0, index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (QModelIndex child, list) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBDocumentProxy *documentProxy= docModel->proxyForIndex(child); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (documentProxy) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (documentProxy->lastUpdate().date() < QDateTime::currentDateTime().addDays(-days).date()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBPersistenceManager::persistenceManager()->deleteDocument(documentProxy); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (docModel->isCatalog(child)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deleteDocumentsInFolderOlderThan(child, days); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::deleteEmptyFolders(const QModelIndex &index) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndexList list; |
|
|
|
|
|
|
|
for (int i = 0; i < docModel->rowCount(index); i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
list << docModel->index(i, 0, index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (list.length() > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (QModelIndex child, list) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (docModel->isCatalog(child)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!docModel->containsDocuments(child)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deleteIndexAndAssociatedData(child); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (docModel->isCatalog(index)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deleteIndexAndAssociatedData(index); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::emptyFolder(const QModelIndex &index, DeletionType pDeletionType) |
|
|
|
void UBDocumentController::emptyFolder(const QModelIndex &index, DeletionType pDeletionType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Issue NC - CFA - 20131029 : ajout d'une popup de confirmation pour la suppression definitive
|
|
|
|
// Issue NC - CFA - 20131029 : ajout d'une popup de confirmation pour la suppression definitive
|
|
|
|