forbid deletion if all pages are selected

preferencesAboutTextFull
Clément Fauconnier 3 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;} void pureSetDocument(UBDocumentProxy *document) {mCurrentDocument = document;}
UBDocumentProxy* selectedDocument(){return mCurrentDocument;} UBDocumentProxy* selectedDocument(){return mCurrentDocument;}
int pageCount(){return mCurrentDocument->pageCount();} int pageCount() const{return mCurrentDocument->pageCount();}
const QPixmap* pageAt(int index) const QPixmap* pageAt(int index)
{ {
if (index < mDocumentThumbs.size()) if (index < mDocumentThumbs.size())

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

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

Loading…
Cancel
Save