fixed issue with handling zero pages

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent 46b33afae3
commit abd1c8cb1a
  1. 10
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 9
      src/adaptors/UBThumbnailAdaptor.cpp
  3. 6
      src/adaptors/publishing/UBDocumentPublisher.cpp
  4. 54
      src/core/UBPersistenceManager.cpp
  5. 1
      src/document/UBDocumentController.cpp
  6. 3
      src/document/UBDocumentController.h
  7. 8
      src/frameworks/UBFileSystemUtils.cpp
  8. 1
      src/gui/UBDocumentNavigator.cpp
  9. 2
      src/gui/UBDocumentTreeWidget.cpp
  10. 3
      src/gui/UBTeacherGuideWidget.cpp
  11. 13
      src/gui/UBThumbnailWidget.cpp

@ -143,7 +143,7 @@ void UBSvgSubsetAdaptor::upgradeScene(UBDocumentProxy* proxy, const int pageInde
QDomDocument UBSvgSubsetAdaptor::loadSceneDocument(UBDocumentProxy* proxy, const int pPageIndex) QDomDocument UBSvgSubsetAdaptor::loadSceneDocument(UBDocumentProxy* proxy, const int pPageIndex)
{ {
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pPageIndex)); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg",pPageIndex);
QFile file(fileName); QFile file(fileName);
QDomDocument doc("page"); QDomDocument doc("page");
@ -166,7 +166,7 @@ QDomDocument UBSvgSubsetAdaptor::loadSceneDocument(UBDocumentProxy* proxy, const
void UBSvgSubsetAdaptor::setSceneUuid(UBDocumentProxy* proxy, const int pageIndex, QUuid pUuid) void UBSvgSubsetAdaptor::setSceneUuid(UBDocumentProxy* proxy, const int pageIndex, QUuid pUuid)
{ {
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg",pageIndex);
QFile file(fileName); QFile file(fileName);
@ -234,7 +234,7 @@ QString UBSvgSubsetAdaptor::uniboardDocumentNamespaceUriFromVersion(int mFileVer
UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int pageIndex) UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int pageIndex)
{ {
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex);
QFile file(fileName); QFile file(fileName);
@ -260,7 +260,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int
QUuid UBSvgSubsetAdaptor::sceneUuid(UBDocumentProxy* proxy, const int pageIndex) QUuid UBSvgSubsetAdaptor::sceneUuid(UBDocumentProxy* proxy, const int pageIndex)
{ {
QString fileName = proxy->persistencePath() + QString fileName = proxy->persistencePath() +
UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex);
QFile file(fileName); QFile file(fileName);
@ -1213,7 +1213,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
} }
mXmlWriter.writeEndDocument(); mXmlWriter.writeEndDocument();
QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(mPageIndex)); QString fileName = mDocumentPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", mPageIndex);
QFile file(fileName); QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))

@ -44,7 +44,7 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
int existingPageCount = proxy->pageCount(); int existingPageCount = proxy->pageCount();
QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", UBApplication::boardController->sceneIndexFromPage(existingPageCount)); QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount);
QFile thumbFile(thumbFileName); QFile thumbFile(thumbFileName);
@ -139,8 +139,7 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
} }
//end compatibility with older format //end compatibility with older format
// QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index + 1); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index);
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", UBApplication::boardController->pageFromSceneIndex(index));
QFile file(fileName); QFile file(fileName);
if (file.exists()) if (file.exists())
@ -159,7 +158,7 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified)
{ {
QString fileName = pDocPath + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString fileName = pDocPath + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
QFile thumbFile(fileName); QFile thumbFile(fileName);
@ -205,7 +204,7 @@ void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene*
QUrl UBThumbnailAdaptor::thumbnailUrl(UBDocumentProxy* proxy, int pageIndex) QUrl UBThumbnailAdaptor::thumbnailUrl(UBDocumentProxy* proxy, int pageIndex)
{ {
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex);
return QUrl::fromLocalFile(fileName); return QUrl::fromLocalFile(fileName);
} }

@ -133,7 +133,7 @@ void UBDocumentPublisher::buildUbwFile()
// remove all useless files // remove all useless files
for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) { for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) {
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg",pageIndex);
QFile::remove(filename); QFile::remove(filename);
} }
@ -193,7 +193,7 @@ void UBDocumentPublisher::rasterizeScenes()
UBSvgSubsetRasterizer rasterizer(mPublishingDocument, pageIndex); UBSvgSubsetRasterizer rasterizer(mPublishingDocument, pageIndex);
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.jpg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.jpg",pageIndex);
rasterizer.rasterizeToFile(filename); rasterizer.rasterizeToFile(filename);
@ -257,7 +257,7 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
} }
} }
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.json", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.json",pageIndex);
QFile jsonFile(filename); QFile jsonFile(filename);
if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate))

@ -427,13 +427,11 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
foreach(int index, compactedIndexes) foreach(int index, compactedIndexes)
{ {
QString svgFileName = proxy->persistencePath() + QString svgFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", index);
UBFileSystemUtils::digitFileFormat("/page%1.svg", index + 1);
QFile::remove(svgFileName); QFile::remove(svgFileName);
QString thumbFileName = proxy->persistencePath() + QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index);
UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index + 1);
QFile::remove(thumbFileName); QFile::remove(thumbFileName);
@ -496,9 +494,7 @@ UBGraphicsScene* UBPersistenceManager::createDocumentSceneAt(UBDocumentProxy* pr
int count = sceneCount(proxy); int count = sceneCount(proxy);
for(int i = count - 1; i >= index; i--) for(int i = count - 1; i >= index; i--)
{
renamePage(proxy, i , i + 1); renamePage(proxy, i , i + 1);
}
mSceneCache.shiftUpScenes(proxy, index, count -1); mSceneCache.shiftUpScenes(proxy, index, count -1);
@ -548,11 +544,11 @@ void UBPersistenceManager::moveSceneToIndex(UBDocumentProxy* proxy, int source,
if (source == target) if (source == target)
return; return;
QFile svgTmp(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", source + 1)); QFile svgTmp(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", source));
svgTmp.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.tmp", target + 1)); svgTmp.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.tmp", target));
QFile thumbTmp(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", source + 1)); QFile thumbTmp(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", source));
thumbTmp.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.tmp", target + 1)); thumbTmp.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.tmp", target));
if (source < target) if (source < target)
{ {
@ -569,11 +565,11 @@ void UBPersistenceManager::moveSceneToIndex(UBDocumentProxy* proxy, int source,
} }
} }
QFile svg(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.tmp", target + 1)); QFile svg(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.tmp", target));
svg.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", target + 1)); svg.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", target));
QFile thumb(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.tmp", target + 1)); QFile thumb(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.tmp", target));
thumb.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", target + 1)); thumb.rename(proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", target));
mSceneCache.moveScene(proxy, source, target); mSceneCache.moveScene(proxy, source, target);
@ -586,10 +582,14 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy,
if (mSceneCache.contains(proxy, sceneIndex)) if (mSceneCache.contains(proxy, sceneIndex))
{ {
//qDebug() << "scene" << sceneIndex << "retrieved from cache ..."; //qDebug() << "scene" << sceneIndex << "retrieved from cache ...";
//updating teacher guide node
//TODO Claudio find a way to store extra information like teacher guid
UBSvgSubsetAdaptor::loadScene(proxy, sceneIndex);
return mSceneCache.value(proxy, sceneIndex); return mSceneCache.value(proxy, sceneIndex);
} }
else else
{ {
qDebug() << "scene" << sceneIndex << "retrieved from file ...";
UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, sceneIndex); UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, sceneIndex);
if (scene) if (scene)
@ -641,23 +641,23 @@ UBDocumentProxy* UBPersistenceManager::persistDocumentMetadata(UBDocumentProxy*
void UBPersistenceManager::renamePage(UBDocumentProxy* pDocumentProxy, const int sourceIndex, const int targetIndex) void UBPersistenceManager::renamePage(UBDocumentProxy* pDocumentProxy, const int sourceIndex, const int targetIndex)
{ {
QFile svg(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sourceIndex + 1)); QFile svg(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sourceIndex));
svg.rename(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", targetIndex + 1)); svg.rename(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", targetIndex));
QFile thumb(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceIndex + 1)); QFile thumb(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceIndex));
thumb.rename(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetIndex + 1)); thumb.rename(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetIndex));
} }
void UBPersistenceManager::copyPage(UBDocumentProxy* pDocumentProxy, const int sourceIndex, const int targetIndex) void UBPersistenceManager::copyPage(UBDocumentProxy* pDocumentProxy, const int sourceIndex, const int targetIndex)
{ {
QFile svg(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sourceIndex + 1)); QFile svg(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg",sourceIndex));
svg.copy(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", targetIndex + 1)); svg.copy(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", targetIndex));
UBSvgSubsetAdaptor::setSceneUuid(pDocumentProxy, targetIndex, QUuid::createUuid()); UBSvgSubsetAdaptor::setSceneUuid(pDocumentProxy, targetIndex, QUuid::createUuid());
QFile thumb(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceIndex + 1)); QFile thumb(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceIndex));
thumb.copy(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetIndex + 1)); thumb.copy(pDocumentProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetIndex));
} }
@ -673,7 +673,7 @@ int UBPersistenceManager::sceneCountInDir(const QString& pPath)
while (moreToProcess) while (moreToProcess)
{ {
QString fileName = pPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex)); QString fileName = pPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex);
QFile file(fileName); QFile file(fileName);
@ -721,13 +721,13 @@ void UBPersistenceManager::addDirectoryContentToDocument(const QString& document
{ {
int targetIndex = targetPageCount + sourceIndex; int targetIndex = targetPageCount + sourceIndex;
QFile svg(documentRootFolder + UBFileSystemUtils::digitFileFormat("/page%1.svg", sourceIndex + 1)); QFile svg(documentRootFolder + UBFileSystemUtils::digitFileFormat("/page%1.svg", sourceIndex));
svg.copy(pDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", targetIndex + 1)); svg.copy(pDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", targetIndex));
UBSvgSubsetAdaptor::setSceneUuid(pDocument, targetIndex, QUuid::createUuid()); UBSvgSubsetAdaptor::setSceneUuid(pDocument, targetIndex, QUuid::createUuid());
QFile thumb(documentRootFolder + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceIndex + 1)); QFile thumb(documentRootFolder + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceIndex));
thumb.copy(pDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetIndex + 1)); thumb.copy(pDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetIndex));
} }
foreach(QString dir, mDocumentSubDirectories) foreach(QString dir, mDocumentSubDirectories)

@ -162,6 +162,7 @@ void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurr
mDocumentUI->documentTreeWidget->scrollToItem(selected); mDocumentUI->documentTreeWidget->scrollToItem(selected);
mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy()); mDocumentThumbs = UBThumbnailAdaptor::load(selectedDocumentProxy());
qDebug() << mDocumentThumbs.size();
refreshDocumentThumbnailsView(); refreshDocumentThumbnailsView();
mSelectionType = Document; mSelectionType = Document;

@ -111,9 +111,6 @@ class UBDocumentController : public QObject
UBDocumentProxy* mCurrentDocument; UBDocumentProxy* mCurrentDocument;
QList<QPixmap> mDocumentThumbs; QList<QPixmap> mDocumentThumbs;
// UBKeyboardPalette *mKeyboardPalette;
private slots: private slots:
void documentZoomSliderValueChanged (int value); void documentZoomSliderValueChanged (int value);
void loadDocumentProxies(); void loadDocumentProxies();

@ -16,6 +16,11 @@
#include "UBFileSystemUtils.h" #include "UBFileSystemUtils.h"
#include <QtGui> #include <QtGui>
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
THIRD_PARTY_WARNINGS_DISABLE THIRD_PARTY_WARNINGS_DISABLE
@ -313,7 +318,8 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath)
QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit) QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit)
{ {
return s.arg(digit, 3, 10, QLatin1Char('0')); int pageDigit = UBApplication::boardController->pageFromSceneIndex(digit);
return s.arg(pageDigit, 3, 10, QLatin1Char('0'));
} }

@ -56,6 +56,7 @@ UBDocumentNavigator::UBDocumentNavigator(QWidget *parent, const char *name):QGra
setFrameShadow(QFrame::Plain); setFrameShadow(QFrame::Plain);
connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage())); connect(UBApplication::boardController, SIGNAL(activeSceneChanged()), this, SLOT(addNewPage()));
connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(generateThumbnails()));
connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(mScene, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int))); connect(UBApplication::boardController, SIGNAL(documentReorganized(int)), this, SLOT(onMovedToIndex(int)));
connect(UBApplication::boardController, SIGNAL(scrollToSelectedPage()), this, SLOT(onScrollToSelectedPage())); connect(UBApplication::boardController, SIGNAL(scrollToSelectedPage()), this, SLOT(onScrollToSelectedPage()));

@ -327,7 +327,7 @@ void UBDocumentTreeWidget::dropEvent(QDropEvent *event)
//due to incorrect generation of thumbnails of invisible scene I've used direct copying of thumbnail files //due to incorrect generation of thumbnails of invisible scene I've used direct copying of thumbnail files
//it's not universal and good way but it's faster //it's not universal and good way but it's faster
QString from = sourceItem.documentProxy()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceItem.sceneIndex() + 1); QString from = sourceItem.documentProxy()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", sourceItem.sceneIndex());
QString to = targetDocProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetDocProxy->pageCount()); QString to = targetDocProxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", targetDocProxy->pageCount());
QFile::remove(to); QFile::remove(to);
QFile::copy(from, to); QFile::copy(from, to);

@ -155,8 +155,6 @@ UBTeacherGuideEditionWidget::~UBTeacherGuideEditionWidget()
void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event) void UBTeacherGuideEditionWidget::showEvent(QShowEvent* event)
{ {
// mpPageTitle->setFocus();
// mpComment->setFocus();
setFocus(); setFocus();
QWidget::showEvent(event); QWidget::showEvent(event);
} }
@ -240,7 +238,6 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged()
int currentPage = UBApplication::boardController->currentPage(); int currentPage = UBApplication::boardController->currentPage();
if(currentPage > 0){ if(currentPage > 0){
cleanData(); cleanData();
qDebug() << "active scene changed current page " << currentPage << " " << UBSvgSubsetAdaptor::sTeacherGuideNode;
load(UBSvgSubsetAdaptor::sTeacherGuideNode); load(UBSvgSubsetAdaptor::sTeacherGuideNode);
mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage)); mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();

@ -18,6 +18,8 @@
#include "UBThumbnailWidget.h" #include "UBThumbnailWidget.h"
#include "UBRubberBand.h" #include "UBRubberBand.h"
#include "board/UBBoardController.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
@ -749,8 +751,10 @@ UBSceneThumbnailNavigPixmap::UBSceneThumbnailNavigPixmap(const QPixmap& pix, UBD
, bCanMoveUp(false) , bCanMoveUp(false)
, bCanMoveDown(false) , bCanMoveDown(false)
{ {
setAcceptsHoverEvents(true); if(UBApplication::boardController->pageFromSceneIndex(pSceneIndex)){
setFlag(QGraphicsItem::ItemIsSelectable, true); setAcceptsHoverEvents(true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
}
} }
UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap() UBSceneThumbnailNavigPixmap::~UBSceneThumbnailNavigPixmap()
@ -822,7 +826,7 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState()
bCanMoveDown = false; bCanMoveDown = false;
UBDocumentProxy* p = proxy(); UBDocumentProxy* p = proxy();
if(NULL != p) if(NULL != p && UBApplication::boardController->pageFromSceneIndex(sceneIndex()))
{ {
int iNbPages = p->pageCount(); int iNbPages = p->pageCount();
if(1 < iNbPages) if(1 < iNbPages)
@ -838,6 +842,8 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState()
} }
} }
} }
if(UBSettings::settings()->teacherGuidePageZeroActivated and sceneIndex()<=1)
bCanMoveUp = false;
if(bCanDelete || bCanMoveUp || bCanMoveDown) if(bCanDelete || bCanMoveUp || bCanMoveDown)
{ {
@ -855,7 +861,6 @@ void UBSceneThumbnailNavigPixmap::deletePage()
void UBSceneThumbnailNavigPixmap::moveUpPage() void UBSceneThumbnailNavigPixmap::moveUpPage()
{ {
UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() - 1); UBApplication::documentController->moveSceneToIndex(proxy(), sceneIndex(), sceneIndex() - 1);
} }

Loading…
Cancel
Save