forbid deletion if all pages are selected

preferencesAboutTextFull
Clément Fauconnier 4 years ago
parent cd4a66f90c
commit 05b6bf87b3
  1. 2
      src/document/UBDocumentContainer.h
  2. 25
      src/document/UBDocumentController.cpp
  3. 1
      src/document/UBDocumentController.h

@ -45,7 +45,7 @@ class UBDocumentContainer : public QObject
void pureSetDocument(UBDocumentProxy *document) {mCurrentDocument = document;}
UBDocumentProxy* selectedDocument(){return mCurrentDocument;}
int pageCount(){return mCurrentDocument->pageCount();}
int pageCount() const{return mCurrentDocument->pageCount();}
const QPixmap* pageAt(int index)
{
if (index < mDocumentThumbs.size())

@ -3360,6 +3360,7 @@ void UBDocumentController::updateActions()
updateExportSubActions(selectedIndex);
bool firstSceneSelected = false;
bool everyPageSelected = false;
if (docSelected) {
mMainWindow->actionDuplicate->setEnabled(!trashSelected);
@ -3539,7 +3540,12 @@ UBDocumentController::deletionTypeForSelection(LastSelectedElementType pTypeSele
, UBDocumentTreeModel *docModel) const
{
if (pTypeSelection == Page) {
if (pTypeSelection == Page)
{
if (everySceneSelected())
{
return NoDeletion;
}
if (!firstAndOnlySceneSelected()) {
return DeletePage;
}
@ -3566,11 +3572,24 @@ UBDocumentController::deletionTypeForSelection(LastSelectedElementType pTypeSele
return NoDeletion;
}
bool UBDocumentController::everySceneSelected() const
{
QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems();
if (selection.count() > 0)
{
UBSceneThumbnailPixmap* p = dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(0));
if (p)
{
return (selection.count() == p->proxy()->pageCount());
}
}
return false;
}
bool UBDocumentController::firstAndOnlySceneSelected() const
{
bool firstSceneSelected = false;
QList<QGraphicsItem*> selection = mDocumentUI->thumbnailWidget->selectedItems();
for(int i = 0; i < selection.count() && !firstSceneSelected; i += 1)
for(int i = 0; i < selection.count(); i += 1)
{
UBSceneThumbnailPixmap* p = dynamic_cast<UBSceneThumbnailPixmap*>(selection.at(i));
if (p)

@ -401,6 +401,7 @@ class UBDocumentController : public UBDocumentContainer
, const QModelIndex &selectedIndex
, UBDocumentTreeModel *docModel) const;
bool firstAndOnlySceneSelected() const;
bool everySceneSelected() const;
QWidget *mainWidget() const {return mDocumentWidget;}
//issue 1629 - NNE - 20131212

Loading…
Cancel
Save