|
|
@ -1803,73 +1803,37 @@ void UBDocumentController::TreeViewSelectionChanged(const QItemSelection &select |
|
|
|
int nbIndexes = selected.indexes().count(); |
|
|
|
int nbIndexes = selected.indexes().count(); |
|
|
|
|
|
|
|
|
|
|
|
if (nbIndexes) { |
|
|
|
if (nbIndexes) { |
|
|
|
//N/C - NNE - 20140408
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QModelIndexList list = mDocumentUI->documentTreeView->selectionModel()->selectedRows(); |
|
|
|
QModelIndexList list = mDocumentUI->documentTreeView->selectionModel()->selectedRows(); |
|
|
|
|
|
|
|
|
|
|
|
//if multi-selection
|
|
|
|
//if multi-selection
|
|
|
|
if(list.count() > 1){ |
|
|
|
if(list.count() > 1) |
|
|
|
//selectOnlyTopLevelItems(mDocumentUI->documentTreeView->selectionModel()->selectedRows());
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i=0; i < list.count() ; i++) |
|
|
|
//check if the selection is in the same top-level folder
|
|
|
|
{ |
|
|
|
QModelIndex sourceIndex1 = mapIndexToSource(list.at(list.count()-1)); |
|
|
|
QModelIndex newSelectedRow = list.at(i); |
|
|
|
QModelIndex sourceIndex2 = mapIndexToSource(list.at(list.count()-2)); |
|
|
|
QModelIndex parent = newSelectedRow.parent(); |
|
|
|
|
|
|
|
bool isParentIsSelected = false; |
|
|
|
|
|
|
|
while(parent.isValid()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
isParentIsSelected |= (list.indexOf(parent) != -1); |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentTreeModel *model = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel; |
|
|
|
if(isParentIsSelected) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
bool sameFolder = (model->inTrash(sourceIndex1) && model->inTrash(sourceIndex2)); |
|
|
|
parent = parent.parent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sameFolder |= (model->inMyDocuments(sourceIndex1) && model->inMyDocuments(sourceIndex2)); |
|
|
|
if(!isParentIsSelected) |
|
|
|
|
|
|
|
TreeViewSelectionChanged(newSelectedRow, QModelIndex()); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
mDocumentUI->documentTreeView->selectionModel()->select(newSelectedRow, QItemSelectionModel::Deselect | QItemSelectionModel::Rows); |
|
|
|
|
|
|
|
|
|
|
|
if(!sameFolder){ |
|
|
|
|
|
|
|
mDocumentUI->documentTreeView->clearSelection(); |
|
|
|
|
|
|
|
mDocumentUI->documentTreeView->selectionModel()->select(list.at(list.count()-1), QItemSelectionModel::Select | QItemSelectionModel::Rows); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//N/C - NNE - 20140408 : END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if the parent has been already select, don't select its children
|
|
|
|
|
|
|
|
QModelIndex newSelectedRow = selected.indexes().first(); |
|
|
|
|
|
|
|
QModelIndex parent = newSelectedRow.parent(); |
|
|
|
|
|
|
|
bool isParentIsSelected = false; |
|
|
|
|
|
|
|
while(parent.isValid()){ |
|
|
|
|
|
|
|
isParentIsSelected |= (list.indexOf(parent) != -1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(isParentIsSelected) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parent = parent.parent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!isParentIsSelected) |
|
|
|
|
|
|
|
TreeViewSelectionChanged(newSelectedRow, QModelIndex()); |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
mDocumentUI->documentTreeView->selectionModel()->select(newSelectedRow, QItemSelectionModel::Deselect | QItemSelectionModel::Rows); |
|
|
|
{ |
|
|
|
|
|
|
|
TreeViewSelectionChanged(selected.indexes().at(0), QModelIndex()); |
|
|
|
//if he newSelectedRow have children deselect them
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
UBDocumentTreeModel *model = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(model->rowCount(newSelectedRow) > 0){ |
|
|
|
|
|
|
|
QModelIndexList children; |
|
|
|
|
|
|
|
QModelIndex parent = newSelectedRow; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//init children list
|
|
|
|
|
|
|
|
for(int i = 0; i < model->rowCount(parent); i++){ |
|
|
|
|
|
|
|
children.push_back(parent.child(i, 0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < children.size(); i++){ |
|
|
|
|
|
|
|
//deselect the element
|
|
|
|
|
|
|
|
mDocumentUI->documentTreeView->selectionModel()->select(children.at(0), QItemSelectionModel::Deselect); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//add its children if any
|
|
|
|
|
|
|
|
for(int k = 0; k < model->rowCount(children.at(i)); k++){ |
|
|
|
|
|
|
|
children.push_back(children.at(i).child(k, 0)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2229,38 +2193,48 @@ void UBDocumentController::deleteSelectedItem() |
|
|
|
if (!UBApplication::mainWindow->yesNoQuestion(tr("Remove Item"), tr("Are you sure you want to remove the selected item(s) ?"))) |
|
|
|
if (!UBApplication::mainWindow->yesNoQuestion(tr("Remove Item"), tr("Are you sure you want to remove the selected item(s) ?"))) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
//we iterate in backward because if we iterate in normal order,
|
|
|
|
if (indexes.size() > 1) |
|
|
|
//indexes are invalid after the first deletion
|
|
|
|
{ |
|
|
|
for(int i = indexes.size()-1; i >= 0; i--){ |
|
|
|
deleteMultipleItems(indexes, docModel); |
|
|
|
QModelIndex currentIndex = indexes.at(i); |
|
|
|
} |
|
|
|
DeletionType deletionForSelection = deletionTypeForSelection(mSelectionType, currentIndex, docModel); |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deleteSingleItem(indexes.at(0), docModel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//N/C - NNE - 20140408 : if parent is selected, continue, because it will be deleted when the parent will be deleted
|
|
|
|
updateActions(); |
|
|
|
if(mDocumentUI->documentTreeView->selectionModel()->isSelected(currentIndex.parent())){ |
|
|
|
} |
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//N/C - NNE - 20140408 : END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (deletionForSelection) { |
|
|
|
void UBDocumentController::deleteMultipleItems(QModelIndexList indexes, UBDocumentTreeModel* docModel) |
|
|
|
case DeletePage: |
|
|
|
{ |
|
|
|
{ |
|
|
|
DeletionType deletionForSelection = deletionTypeForSelection(mSelectionType, indexes.at(0), docModel); |
|
|
|
deletePages(mDocumentUI->thumbnailWidget->selectedItems()); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case MoveToTrash: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
moveToTrash(currentIndex, docModel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
switch (deletionForSelection) |
|
|
|
} |
|
|
|
{ |
|
|
|
case CompleteDelete: |
|
|
|
case DeletePage: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deletePages(mDocumentUI->thumbnailWidget->selectedItems()); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case MoveToTrash: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
moveIndexesToTrash(indexes, docModel); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case CompleteDelete: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i =0; i < indexes.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
deleteIndexAndAssociatedData(currentIndex); |
|
|
|
deleteIndexAndAssociatedData(indexes.at(i)); |
|
|
|
emit documentThumbnailsUpdated(this); |
|
|
|
emit documentThumbnailsUpdated(this); |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
case EmptyFolder: |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case EmptyFolder: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i =0; i < indexes.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QModelIndex currentIndex = indexes.at(i); |
|
|
|
if (currentIndex == docModel->myDocumentsIndex()) { //Emptying "My documents". Keeping Untitled Documents
|
|
|
|
if (currentIndex == docModel->myDocumentsIndex()) { //Emptying "My documents". Keeping Untitled Documents
|
|
|
|
int startInd = 0; |
|
|
|
int startInd = 0; |
|
|
|
while (docModel->rowCount(currentIndex)) { |
|
|
|
while (docModel->rowCount(currentIndex)) { |
|
|
@ -2288,14 +2262,81 @@ void UBDocumentController::deleteSelectedItem() |
|
|
|
|
|
|
|
|
|
|
|
if(deleteCurrentScene) createNewDocumentInUntitledFolder(); |
|
|
|
if(deleteCurrentScene) createNewDocumentInUntitledFolder(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
case EmptyTrash: |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case EmptyTrash: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i=0; i < indexes.size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
emptyFolder(currentIndex, CompleteDelete); // Empty trash folder
|
|
|
|
emptyFolder(indexes.at(i), CompleteDelete); // Empty trash folder
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
updateActions(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBDocumentController::deleteSingleItem(QModelIndex currentIndex, UBDocumentTreeModel* docModel) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
DeletionType deletionForSelection = deletionTypeForSelection(mSelectionType, currentIndex, docModel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (deletionForSelection) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case DeletePage: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deletePages(mDocumentUI->thumbnailWidget->selectedItems()); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case MoveToTrash: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
moveToTrash(currentIndex, docModel); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case CompleteDelete: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
deleteIndexAndAssociatedData(currentIndex); |
|
|
|
|
|
|
|
emit documentThumbnailsUpdated(this); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case EmptyFolder: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (currentIndex == docModel->myDocumentsIndex()) { //Emptying "My documents". Keeping Untitled Documents
|
|
|
|
|
|
|
|
int startInd = 0; |
|
|
|
|
|
|
|
while (docModel->rowCount(currentIndex)) { |
|
|
|
|
|
|
|
QModelIndex testSubINdecurrentIndex = docModel->index(startInd, 0, currentIndex); |
|
|
|
|
|
|
|
if (testSubINdecurrentIndex == docModel->untitledDocumentsIndex()) { |
|
|
|
|
|
|
|
emptyFolder(testSubINdecurrentIndex, MoveToTrash); |
|
|
|
|
|
|
|
startInd++; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!testSubINdecurrentIndex.isValid()) { |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
docModel->moveIndex(testSubINdecurrentIndex, docModel->trashIndex()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//issue 1629 - NNE - 20131105
|
|
|
|
|
|
|
|
//Here, we are sure that the current scene has been deleted
|
|
|
|
|
|
|
|
createNewDocumentInUntitledFolder(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
//issue 1629 - NNE - 20131105
|
|
|
|
|
|
|
|
//Check if we will delete the current scene
|
|
|
|
|
|
|
|
UBDocumentTreeNode *currentNode = docModel->nodeFromIndex(currentIndex); |
|
|
|
|
|
|
|
bool deleteCurrentScene = currentNode->findNode(docModel->nodeFromIndex(docModel->currentIndex())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emptyFolder(currentIndex, MoveToTrash); //Empty constant folder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(deleteCurrentScene) createNewDocumentInUntitledFolder(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case EmptyTrash: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
emptyFolder(currentIndex, CompleteDelete); // Empty trash folder
|
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
updateActions(); |
|
|
|
updateActions(); |
|
|
@ -2332,14 +2373,17 @@ void UBDocumentController::moveIndexesToTrash(const QModelIndexList &list, UBDoc |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentProxy *proxy = docModel->proxyForIndex(sourceSibling); |
|
|
|
UBDocumentProxy *proxy = docModel->proxyForIndex(sourceSibling); |
|
|
|
|
|
|
|
|
|
|
|
setDocument(proxy); |
|
|
|
if (proxy) |
|
|
|
UBApplication::boardController->setActiveDocumentScene(proxy,0,true); |
|
|
|
{ |
|
|
|
docModel->setCurrentDocument(proxy); |
|
|
|
setDocument(proxy); |
|
|
|
|
|
|
|
UBApplication::boardController->setActiveDocumentScene(proxy,0,true); |
|
|
|
|
|
|
|
docModel->setCurrentDocument(proxy); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectionModel->select(sibling, QItemSelectionModel::ClearAndSelect); |
|
|
|
selectionModel->select(sibling, QItemSelectionModel::ClearAndSelect); |
|
|
|
|
|
|
|
|
|
|
|
deleteCurrentScene = false; |
|
|
|
deleteCurrentScene = false; |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
sibling = findNextSiblingNotSelected(proxyMapCurentScene, selectionModel); |
|
|
|
sibling = findNextSiblingNotSelected(proxyMapCurentScene, selectionModel); |
|
|
|
|
|
|
|
|
|
|
@ -2348,13 +2392,16 @@ void UBDocumentController::moveIndexesToTrash(const QModelIndexList &list, UBDoc |
|
|
|
|
|
|
|
|
|
|
|
UBDocumentProxy *proxy = docModel->proxyForIndex(sourceSibling); |
|
|
|
UBDocumentProxy *proxy = docModel->proxyForIndex(sourceSibling); |
|
|
|
|
|
|
|
|
|
|
|
setDocument(proxy); |
|
|
|
if (proxy) |
|
|
|
UBApplication::boardController->setActiveDocumentScene(proxy,0,true); |
|
|
|
{ |
|
|
|
docModel->setCurrentDocument(proxy); |
|
|
|
setDocument(proxy); |
|
|
|
|
|
|
|
UBApplication::boardController->setActiveDocumentScene(proxy,0,true); |
|
|
|
|
|
|
|
docModel->setCurrentDocument(proxy); |
|
|
|
|
|
|
|
|
|
|
|
selectionModel->select(sibling, QItemSelectionModel::ClearAndSelect); |
|
|
|
selectionModel->select(sibling, QItemSelectionModel::ClearAndSelect); |
|
|
|
|
|
|
|
|
|
|
|
deleteCurrentScene = false; |
|
|
|
deleteCurrentScene = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|