Commit e0b1417e authored by Clément Fauconnier's avatar Clément Fauconnier

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

parent 4dfdbe9b
...@@ -2500,23 +2500,36 @@ QModelIndex UBDocumentController::findPreviousSiblingNotSelected(const QModelInd ...@@ -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)){ {
return sibling; QModelIndex model = mSortFilterProxyModel->mapToSource(sibling);
}else{
if(UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel->isCatalog(model))
{
return findPreviousSiblingNotSelected(sibling, selectionModel);
}
else
{
return sibling;
}
}
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 & ...@@ -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();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment