Commit fc15dfe4 authored by Claudio Valerio's avatar Claudio Valerio

exported all the logic for page actions on UBDocumentController

parent 8eebc632
...@@ -1645,3 +1645,29 @@ int UBDocumentController::getSelectedItemIndex() ...@@ -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 ...@@ -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 ...@@ -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;
} }
......
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