exported all the logic for page actions on UBDocumentController

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 8eebc6320f
commit fc15dfe45c
  1. 26
      src/document/UBDocumentController.cpp
  2. 5
      src/document/UBDocumentController.h
  3. 38
      src/gui/UBThumbnailWidget.cpp

@ -1645,3 +1645,29 @@ int UBDocumentController::getSelectedItemIndex()
} }
else return -1; else return -1;
} }
bool UBDocumentController::pageCanBeMovedUp(int page)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return page >= 2;
else
return page >= 1;
}
bool UBDocumentController::pageCanBeMovedDown(int page)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return page != 0 && page < mCurrentDocument->pageCount() - 1;
else
return page < mCurrentDocument->pageCount() - 1;
}
bool UBDocumentController::pageCanBeDuplicated(int page)
{
return page != 0;
}
bool UBDocumentController::pageCanBeDeleted(int page)
{
return page != 0;
}

@ -51,6 +51,11 @@ class UBDocumentController : public QObject
void deletePages(QList<QGraphicsItem*> itemsToDelete); void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex(); int getSelectedItemIndex();
bool pageCanBeMovedUp(int page);
bool pageCanBeMovedDown(int page);
bool pageCanBeDuplicated(int page);
bool pageCanBeDeleted(int page);
signals: signals:
void refreshThumbnails(); void refreshThumbnails();
void exportDone(); void exportDone();

@ -823,40 +823,22 @@ void UBSceneThumbnailNavigPixmap::mousePressEvent(QGraphicsSceneMouseEvent *even
void UBSceneThumbnailNavigPixmap::updateButtonsState() void UBSceneThumbnailNavigPixmap::updateButtonsState()
{ {
bCanDelete = false;
bCanMoveUp = false;
bCanMoveDown = false;
bCanDuplicate = true;
UBDocumentProxy* p = proxy();
if(NULL != p && 0 <= UBApplication::boardController->pageFromSceneIndex(sceneIndex()))
{
int iNbPages = p->pageCount();
if(1 < iNbPages)
{
bCanDelete = true;
if(sceneIndex() > 0)
{
bCanMoveUp = true;
}
if(sceneIndex() != iNbPages - 1)
{
bCanMoveDown = true;
}
}
}
if(UBSettings::settings()->teacherGuidePageZeroActivated && sceneIndex()<=1)
bCanMoveUp = false;
if(UBSettings::settings()->teacherGuidePageZeroActivated && sceneIndex() == 0){
bCanDelete = false; bCanDelete = false;
bCanDuplicate = false;
bCanMoveUp = false; bCanMoveUp = false;
bCanMoveDown = false; bCanMoveDown = false;
} bCanDuplicate = false;
if(proxy()){
int pageIndex = UBApplication::boardController->pageFromSceneIndex(sceneIndex());
UBDocumentController* documentController = UBApplication::documentController;
bCanDelete = documentController->pageCanBeDeleted(pageIndex);
bCanMoveUp = documentController->pageCanBeMovedUp(pageIndex);
bCanMoveDown = documentController->pageCanBeMovedDown(pageIndex);
bCanDuplicate = documentController->pageCanBeDuplicated(pageIndex);
}
if(bCanDelete || bCanMoveUp || bCanMoveDown) if(bCanDelete || bCanMoveUp || bCanMoveDown || bCanDuplicate)
bButtonsVisible = true; bButtonsVisible = true;
} }

Loading…
Cancel
Save