improvements in selection of another document when the current one selected is deleted

preferencesAboutTextFull
Clément Fauconnier 5 years ago
parent 4dfdbe9b72
commit e0b1417e0f
  1. 64
      src/document/UBDocumentController.cpp

@ -2500,23 +2500,36 @@ QModelIndex UBDocumentController::findPreviousSiblingNotSelected(const QModelInd
{ {
QModelIndex sibling = index.sibling(index.row() - 1, 0); QModelIndex sibling = index.sibling(index.row() - 1, 0);
if(sibling.isValid()){ if(sibling.isValid())
//if sibling is not selected and it is a document {
//else keep searching
if(!parentIsSelected(sibling, selectionModel) if(!parentIsSelected(sibling, selectionModel)
&& !selectionModel->isSelected(sibling) && !selectionModel->isSelected(sibling))
&& !sibling.model()->hasChildren(sibling)){ {
QModelIndex model = mSortFilterProxyModel->mapToSource(sibling);
if(UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->isCatalog(model))
{
return findPreviousSiblingNotSelected(sibling, selectionModel);
}
else
{
return sibling; return sibling;
}else{ }
}
else
{
return findPreviousSiblingNotSelected(sibling, selectionModel); return findPreviousSiblingNotSelected(sibling, selectionModel);
} }
}else{ }else{
//if the parent exist keep searching, else stop the search //if the parent exist keep searching, else stop the search
QModelIndex parent = index.model()->parent(index); QModelIndex parent = index.model()->parent(index);
if(parent.isValid()){ if(parent.isValid())
{
return findPreviousSiblingNotSelected(parent, selectionModel); return findPreviousSiblingNotSelected(parent, selectionModel);
}else{ }
else
{
return QModelIndex(); return QModelIndex();
} }
} }
@ -2526,29 +2539,38 @@ QModelIndex UBDocumentController::findNextSiblingNotSelected(const QModelIndex &
{ {
QModelIndex sibling = index.sibling(index.row() + 1, 0); QModelIndex sibling = index.sibling(index.row() + 1, 0);
if(sibling.isValid()){ if(sibling.isValid())
//if sibling is not selected and it is a document and its parent are not selected {
//else keep searching
if(!parentIsSelected(sibling, selectionModel) if(!parentIsSelected(sibling, selectionModel)
&& !selectionModel->isSelected(sibling) && !selectionModel->isSelected(sibling))
&& !sibling.model()->hasChildren(sibling)){ {
QModelIndex model = mSortFilterProxyModel->mapToSource(index); QModelIndex model = mSortFilterProxyModel->mapToSource(sibling);
if(UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->isCatalog(model)){ if(UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->isCatalog(model))
return QModelIndex(); {
}else{ return findNextSiblingNotSelected(sibling, selectionModel);
}
else
{
return sibling; return sibling;
} }
}else{ }
else
{
return findNextSiblingNotSelected(sibling, selectionModel); return findNextSiblingNotSelected(sibling, selectionModel);
} }
}else{ }
else
{
//if the parent exist keep searching, else stop the search //if the parent exist keep searching, else stop the search
QModelIndex parent = index.parent(); QModelIndex parent = index.parent();
if(parent.isValid()){ if(parent.isValid())
{
return findNextSiblingNotSelected(parent, selectionModel); return findNextSiblingNotSelected(parent, selectionModel);
}else{ }
else
{
return QModelIndex(); return QModelIndex();
} }
} }

Loading…
Cancel
Save