first page handling code

preferencesAboutTextFull
Claudio Valerio 13 years ago
parent f85bb2d5fa
commit 7ee53b07ad
  1. 15
      resources/style.qss
  2. 1
      src/adaptors/UBImportImage.cpp
  3. 1
      src/adaptors/UBImportPDF.cpp
  4. 20
      src/adaptors/UBThumbnailAdaptor.cpp
  5. 12
      src/adaptors/publishing/UBDocumentPublisher.cpp
  6. 9
      src/board/UBBoardController.cpp
  7. 2
      src/board/UBBoardController.h
  8. 4
      src/board/UBBoardPaletteManager.cpp
  9. 15
      src/board/UBBoardView.cpp
  10. 114
      src/board/UBFeaturesController.h
  11. 44
      src/core/UBPersistenceManager.cpp
  12. 6
      src/core/UBPersistenceManager.h
  13. 2
      src/gui/UBDocumentNavigator.cpp
  14. 5
      src/gui/UBNavigatorPalette.cpp
  15. 22
      src/gui/UBTeacherGuideWidget.cpp
  16. 1
      src/gui/UBThumbnailWidget.cpp

@ -227,19 +227,13 @@ QLabel#UBTGPresentationDocumentTitle
font-weight:bold; font-weight:bold;
} }
QLabel#UBTGEditionPageNumberLabel QLabel#UBTGPageNumberLabel
{ {
color: black; color: black;
font-size : 12px; font-size : 12px;
font-weight:bold; font-weight:bold;
} }
QLabel#UBTGPresentationPageNumberLabel
{
color: black;
font-size : 12px;
}
UBTGAdaptableText#UBTGEditionPageTitle, UBTGAdaptableText#UBTGEditionPageTitle,
UBTGAdaptableText#UBTGEditionComment UBTGAdaptableText#UBTGEditionComment
{ {
@ -266,3 +260,10 @@ QFrame#UBTGSeparator
{ {
background-color: #cccccc; background-color: #cccccc;
} }
UBTGAdaptableText {
background-color: white;
border:1 solid #999999;
border-radius : 10px;
padding: 2px;
}

@ -14,7 +14,6 @@
*/ */
#include "UBImportImage.h" #include "UBImportImage.h"
#include "UBSvgSubsetAdaptor.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"

@ -14,7 +14,6 @@
*/ */
#include "UBImportPDF.h" #include "UBImportPDF.h"
#include "UBSvgSubsetAdaptor.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"

@ -23,6 +23,8 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "board/UBBoardController.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
@ -42,8 +44,7 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
int existingPageCount = proxy->pageCount(); int existingPageCount = proxy->pageCount();
QString thumbFileName = proxy->persistencePath() + QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount);
UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount);
QFile thumbFile(thumbFileName); QFile thumbFile(thumbFileName);
@ -80,8 +81,7 @@ QList<QPixmap> UBThumbnailAdaptor::load(UBDocumentProxy* proxy)
while (moreToProcess) { while (moreToProcess) {
pageCount++; pageCount++;
QString fileName = proxy->persistencePath() + QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageCount);
UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageCount);
QFile file(fileName); QFile file(fileName);
if (file.exists()) { if (file.exists()) {
@ -108,8 +108,7 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
return QPixmap(); return QPixmap();
//compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails
QString thumbFileName = proxy->persistencePath() + QString thumbFileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount);
UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount);
QFile thumbFile(thumbFileName); QFile thumbFile(thumbFileName);
@ -140,8 +139,8 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index)
} }
//end compatibility with older format //end compatibility with older format
QString fileName = proxy->persistencePath() + // QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index + 1);
UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index + 1); 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())
@ -160,7 +159,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", pageIndex + 1); QString fileName = pDocPath + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
QFile thumbFile(fileName); QFile thumbFile(fileName);
@ -206,8 +205,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() + QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex + 1);
return QUrl::fromLocalFile(fileName); return QUrl::fromLocalFile(fileName);
} }

@ -28,6 +28,8 @@
#include "core/UBPersistenceManager.h" #include "core/UBPersistenceManager.h"
#include "core/UBApplicationController.h" #include "core/UBApplicationController.h"
#include "board/UBBoardController.h"
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
@ -131,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", pageIndex + 1); QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
QFile::remove(filename); QFile::remove(filename);
} }
@ -187,11 +189,11 @@ void UBDocumentPublisher::rasterizeScenes()
for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++) for (int pageIndex = 0; pageIndex < mPublishingDocument->pageCount(); pageIndex++)
{ {
UBApplication::showMessage(tr("Converting page %1/%2 ...").arg(pageIndex + 1).arg(mPublishingDocument->pageCount()), true); UBApplication::showMessage(tr("Converting page %1/%2 ...").arg(UBApplication::boardController->pageFromSceneIndex(pageIndex)).arg(mPublishingDocument->pageCount()), true);
UBSvgSubsetRasterizer rasterizer(mPublishingDocument, pageIndex); UBSvgSubsetRasterizer rasterizer(mPublishingDocument, pageIndex);
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.jpg", pageIndex + 1); QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.jpg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
rasterizer.rasterizeToFile(filename); rasterizer.rasterizeToFile(filename);
@ -250,12 +252,12 @@ void UBDocumentPublisher::upgradeDocumentForPublishing()
UBGraphicsW3CWidgetItem *widgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(item); UBGraphicsW3CWidgetItem *widgetItem = dynamic_cast<UBGraphicsW3CWidgetItem*>(item);
if(widgetItem){ if(widgetItem){
generateWidgetPropertyScript(widgetItem, pageIndex + 1); generateWidgetPropertyScript(widgetItem, UBApplication::boardController->pageFromSceneIndex(pageIndex));
widgets << widgetItem; widgets << widgetItem;
} }
} }
QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.json", pageIndex + 1); QString filename = mPublishingDocument->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.json", UBApplication::boardController->pageFromSceneIndex(pageIndex));
QFile jsonFile(filename); QFile jsonFile(filename);
if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) if (jsonFile.open(QIODevice::WriteOnly | QIODevice::Truncate))

@ -151,11 +151,18 @@ UBBoardController::~UBBoardController()
int UBBoardController::currentPage() int UBBoardController::currentPage()
{ {
if(!UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()) if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return mActiveSceneIndex; return mActiveSceneIndex;
return mActiveSceneIndex + 1; return mActiveSceneIndex + 1;
} }
int UBBoardController::pageFromSceneIndex(int sceneIndex)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return sceneIndex;
return sceneIndex+1;
}
void UBBoardController::setupViews() void UBBoardController::setupViews()
{ {
mControlContainer = new QWidget(mMainWindow->centralWidget()); mControlContainer = new QWidget(mMainWindow->centralWidget());

@ -59,6 +59,8 @@ class UBBoardController : public QObject
int currentPage(); int currentPage();
int pageFromSceneIndex(int sceneIndex);
UBDocumentProxy* activeDocument() UBDocumentProxy* activeDocument()
{ {
return mActiveDocument; return mActiveDocument;

@ -153,7 +153,7 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
mRightPalette = new UBRightPalette(mContainer); mRightPalette = new UBRightPalette(mContainer);
// RIGHT palette widgets // RIGHT palette widgets
mpFeaturesWidget = new UBFeaturesWidget();
mRightPalette->registerWidget(mpFeaturesWidget); mRightPalette->registerWidget(mpFeaturesWidget);
mRightPalette->addTab(mpFeaturesWidget); mRightPalette->addTab(mpFeaturesWidget);
@ -534,7 +534,7 @@ void UBBoardPaletteManager::activeSceneChanged()
if (mpPageNavigWidget) if (mpPageNavigWidget)
{ {
mpPageNavigWidget->setPageNumber(pageIndex + 1, activeScene->document()->pageCount()); mpPageNavigWidget->setPageNumber(UBApplication::boardController->pageFromSceneIndex(pageIndex), activeScene->document()->pageCount());
} }
if (mZoomPalette) if (mZoomPalette)

@ -585,9 +585,9 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
else QGraphicsView::mouseMoveEvent (event); else QGraphicsView::mouseMoveEvent (event);
} }
else if ((UBDrawingController::drawingController()->isDrawingTool()) else if ((UBDrawingController::drawingController()->isDrawingTool())
&& !mMouseButtonIsPressed) && !mMouseButtonIsPressed)
{ {
QGraphicsView::mouseMoveEvent (event); QGraphicsView::mouseMoveEvent (event);
} }
else if (currentTool == UBStylusTool::Text || currentTool == UBStylusTool::Capture) else if (currentTool == UBStylusTool::Text || currentTool == UBStylusTool::Capture)
{ {
@ -849,11 +849,12 @@ void UBBoardView::dropEvent (QDropEvent *event)
graphicsWidget->processDropEvent(event); graphicsWidget->processDropEvent(event);
event->acceptProposedAction(); event->acceptProposedAction();
} else if (!event->source() } else if (!event->source()
|| dynamic_cast<UBThumbnailWidget *>(event->source()) || dynamic_cast<UBThumbnailWidget *>(event->source())
|| dynamic_cast<QWebView*>(event->source()) || dynamic_cast<QWebView*>(event->source())
|| dynamic_cast<UBTGMediaWidget*>(event->source()) || dynamic_cast<UBTGMediaWidget*>(event->source())
|| dynamic_cast<QListView *>(event->source()) ) { || dynamic_cast<QListView *>(event->source())
|| dynamic_cast<UBTGDraggableTreeItem*>(event->source())) {
mController->processMimeData (event->mimeData (), mapToScene (event->pos ())); mController->processMimeData (event->mimeData (), mapToScene (event->pos ()));
event->acceptProposedAction(); event->acceptProposedAction();

@ -8,39 +8,37 @@
#include <QString> #include <QString>
#include <QPixmap> #include <QPixmap>
//#include "UBDockPaletteWidget.h"
enum UBFeatureElementType enum UBFeatureElementType
{ {
FEATURE_CATEGORY, FEATURE_CATEGORY,
FEATURE_VIRTUALFOLDER, FEATURE_VIRTUALFOLDER,
FEATURE_FOLDER, FEATURE_FOLDER,
FEATURE_INTERACTIVE, FEATURE_INTERACTIVE,
FEATURE_INTERNAL, FEATURE_INTERNAL,
FEATURE_ITEM, FEATURE_ITEM,
FEATURE_TRASH, FEATURE_TRASH,
FEATURE_FAVORITE FEATURE_FAVORITE
}; };
class UBFeature class UBFeature
{ {
public: public:
UBFeature() {;} UBFeature() {;}
//UBFeature(const UBFeature &f); //UBFeature(const UBFeature &f);
UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type = FEATURE_CATEGORY); UBFeature(const QString &url, const QPixmap &icon, const QString &name, const QString &realPath, UBFeatureElementType type = FEATURE_CATEGORY);
virtual ~UBFeature() {;} virtual ~UBFeature() {;}
QString getName() const { return mName; } QString getName() const { return mName; }
QPixmap getThumbnail() const {return mThumbnail;} QPixmap getThumbnail() const {return mThumbnail;}
QString getUrl() const { return virtualPath; } QString getUrl() const { return virtualPath; }
//QString getPath() const { return mPath; }; //QString getPath() const { return mPath; };
QString getFullPath() const { return mPath; } QString getFullPath() const { return mPath; }
UBFeatureElementType getType() const { return elementType; } UBFeatureElementType getType() const { return elementType; }
bool isFolder() const; bool isFolder() const;
private: private:
QString virtualPath; QString virtualPath;
QPixmap mThumbnail; QPixmap mThumbnail;
QString mName; QString mName;
QString mPath; QString mPath;
UBFeatureElementType elementType; UBFeatureElementType elementType;
}; };
Q_DECLARE_METATYPE( UBFeature ) Q_DECLARE_METATYPE( UBFeature )
@ -50,73 +48,73 @@ class UBFeaturesController : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
UBFeaturesController(QWidget *parentWidget); UBFeaturesController(QWidget *parentWidget);
virtual ~UBFeaturesController(); virtual ~UBFeaturesController();
QList <UBFeature>* getFeatures()const { return featuresList; } QList <UBFeature>* getFeatures()const { return featuresList; }
const QString& getRootPath()const { return rootPath; } const QString& getRootPath()const { return rootPath; }
void addItemToPage(const UBFeature &item); void addItemToPage(const UBFeature &item);
const UBFeature& getCurrentElement()const { return currentElement; } const UBFeature& getCurrentElement()const { return currentElement; }
void setCurrentElement( const UBFeature &elem ) { currentElement = elem; } void setCurrentElement( const UBFeature &elem ) { currentElement = elem; }
const UBFeature & getTrashElement () const { return trashElement; } const UBFeature & getTrashElement () const { return trashElement; }
UBFeature moveItemToFolder( const QUrl &url, const UBFeature &destination ); UBFeature moveItemToFolder( const QUrl &url, const UBFeature &destination );
UBFeature copyItemToFolder( const QUrl &url, const UBFeature &destination ); UBFeature copyItemToFolder( const QUrl &url, const UBFeature &destination );
void deleteItem( const QUrl &url ); void deleteItem( const QUrl &url );
bool isTrash( const QUrl &url ); bool isTrash( const QUrl &url );
UBFeature newFolder( const QString &name ); UBFeature newFolder( const QString &name );
UBFeature addToFavorite( const QUrl &path ); UBFeature addToFavorite( const QUrl &path );
void removeFromFavorite( const QUrl &path ); void removeFromFavorite( const QUrl &path );
static QString fileNameFromUrl( const QUrl &url ); static QString fileNameFromUrl( const QUrl &url );
static QPixmap thumbnailForFile( const QString &path ); static QPixmap thumbnailForFile( const QString &path );
private: private:
void initDirectoryTree(); void initDirectoryTree();
void fileSystemScan(const QString &currPath, const QString & currVirtualPath); void fileSystemScan(const QString &currPath, const QString & currVirtualPath);
static QPixmap createThumbnail(const QString &path); static QPixmap createThumbnail(const QString &path);
//void addImageToCurrentPage( const QString &path ); //void addImageToCurrentPage( const QString &path );
void loadFavoriteList(); void loadFavoriteList();
void saveFavoriteList(); void saveFavoriteList();
static UBFeatureElementType fileTypeFromUrl( const QString &path ); static UBFeatureElementType fileTypeFromUrl( const QString &path );
QList <UBFeature> *featuresList; QList <UBFeature> *featuresList;
UBFeature *rootElement; UBFeature *rootElement;
QString mUserAudioDirectoryPath; QString mUserAudioDirectoryPath;
QString mUserVideoDirectoryPath; QString mUserVideoDirectoryPath;
QString mUserPicturesDirectoryPath; QString mUserPicturesDirectoryPath;
QString mUserInteractiveDirectoryPath; QString mUserInteractiveDirectoryPath;
QString mUserAnimationDirectoryPath; QString mUserAnimationDirectoryPath;
QString libraryPath; QString libraryPath;
QString mLibAudioDirectoryPath; QString mLibAudioDirectoryPath;
QString mLibVideoDirectoryPath; QString mLibVideoDirectoryPath;
QString mLibPicturesDirectoryPath; QString mLibPicturesDirectoryPath;
QString mLibInteractiveDirectoryPath; QString mLibInteractiveDirectoryPath;
QString mLibAnimationDirectoryPath; QString mLibAnimationDirectoryPath;
QString mLibApplicationsDirectoryPath; QString mLibApplicationsDirectoryPath;
QString mLibShapesDirectoryPath; QString mLibShapesDirectoryPath;
QString trashDirectoryPath; QString trashDirectoryPath;
QString rootPath; QString rootPath;
QString audiosPath; QString audiosPath;
QString moviesPath; QString moviesPath;
QString picturesPath; QString picturesPath;
QString appPath; QString appPath;
QString flashPath; QString flashPath;
QString shapesPath; QString shapesPath;
QString interactPath; QString interactPath;
QString trashPath; QString trashPath;
QString favoritePath; QString favoritePath;
int mLastItemOffsetIndex; int mLastItemOffsetIndex;
UBFeature currentElement; UBFeature currentElement;
UBFeature trashElement; UBFeature trashElement;
UBFeature favoriteElement; UBFeature favoriteElement;
QSet <QString> *favoriteSet; QSet <QString> *favoriteSet;
}; };

@ -32,6 +32,10 @@
#include "adaptors/UBThumbnailAdaptor.h" #include "adaptors/UBThumbnailAdaptor.h"
#include "adaptors/UBMetadataDcSubsetAdaptor.h" #include "adaptors/UBMetadataDcSubsetAdaptor.h"
#include "board/UBBoardController.h"
#include "interfaces/IDataStorage.h"
#include "core/memcheck.h" #include "core/memcheck.h"
const QString UBPersistenceManager::imageDirectory = "images"; // added to UBPersistenceManager::mAllDirectories const QString UBPersistenceManager::imageDirectory = "images"; // added to UBPersistenceManager::mAllDirectories
@ -39,6 +43,7 @@ const QString UBPersistenceManager::objectDirectory = "objects"; // added to UBP
const QString UBPersistenceManager::widgetDirectory = "widgets"; // added to UBPersistenceManager::mAllDirectories const QString UBPersistenceManager::widgetDirectory = "widgets"; // added to UBPersistenceManager::mAllDirectories
const QString UBPersistenceManager::videoDirectory = "videos"; // added to UBPersistenceManager::mAllDirectories const QString UBPersistenceManager::videoDirectory = "videos"; // added to UBPersistenceManager::mAllDirectories
const QString UBPersistenceManager::audioDirectory = "audios"; // added to const QString UBPersistenceManager::audioDirectory = "audios"; // added to
const QString UBPersistenceManager::teacherGuideDirectory = "teacherGuideObjects";
UBPersistenceManager * UBPersistenceManager::sSingleton = 0; UBPersistenceManager * UBPersistenceManager::sSingleton = 0;
@ -52,6 +57,7 @@ UBPersistenceManager::UBPersistenceManager(QObject *pParent)
mDocumentSubDirectories << widgetDirectory; mDocumentSubDirectories << widgetDirectory;
mDocumentSubDirectories << videoDirectory; mDocumentSubDirectories << videoDirectory;
mDocumentSubDirectories << audioDirectory; mDocumentSubDirectories << audioDirectory;
mDocumentSubDirectories << teacherGuideDirectory;
documentProxies = allDocumentProxies(); documentProxies = allDocumentProxies();
emit proxyListChanged(); emit proxyListChanged();
@ -83,7 +89,6 @@ UBPersistenceManager::~UBPersistenceManager()
} }
} }
QList<QPointer<UBDocumentProxy> > UBPersistenceManager::allDocumentProxies() QList<QPointer<UBDocumentProxy> > UBPersistenceManager::allDocumentProxies()
{ {
mDocumentRepositoryPath = UBSettings::userDocumentDirectory(); mDocumentRepositoryPath = UBSettings::userDocumentDirectory();
@ -363,7 +368,7 @@ UBDocumentProxy* UBPersistenceManager::duplicateDocument(UBDocumentProxy* pDocum
void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QList<int>& indexes) void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QList<int>& indexes)
{ {
checkIfDocumentRepositoryExists(); checkIfDocumentRepositoryExists();
int pageCount = UBPersistenceManager::persistenceManager()->sceneCount(proxy); int pageCount = UBPersistenceManager::persistenceManager()->sceneCount(proxy);
@ -432,7 +437,7 @@ void UBPersistenceManager::deleteDocumentScenes(UBDocumentProxy* proxy, const QL
QFile::remove(thumbFileName); QFile::remove(thumbFileName);
mSceneCache.removeScene(proxy, index); mSceneCache.removeScene(proxy, index);
proxy->decPageCount(); proxy->decPageCount();
@ -482,7 +487,7 @@ void UBPersistenceManager::duplicateDocumentScene(UBDocumentProxy* proxy, int in
proxy->incPageCount(); proxy->incPageCount();
emit documentSceneCreated(proxy, index + 1); emit documentSceneCreated(proxy, index + 1);
} }
@ -668,7 +673,7 @@ int UBPersistenceManager::sceneCountInDir(const QString& pPath)
while (moreToProcess) while (moreToProcess)
{ {
QString fileName = pPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex + 1); QString fileName = pPath + UBFileSystemUtils::digitFileFormat("/page%1.svg", UBApplication::boardController->pageFromSceneIndex(pageIndex));
QFile file(fileName); QFile file(fileName);
@ -828,6 +833,35 @@ void UBPersistenceManager::purgeEmptyDocuments()
} }
} }
QString UBPersistenceManager::teacherGuideAbsoluteObjectPath(UBDocumentProxy* pDocumentProxy)
{
return pDocumentProxy->persistencePath() + "/" + teacherGuideDirectory;
}
QString UBPersistenceManager::addObjectToTeacherGuideDirectory(UBDocumentProxy* pDocumentProxy, QString pPath)
{
QFileInfo fi(pPath.replace("file://",""));
QString uuid = QUuid::createUuid();
if (!fi.exists() || !pDocumentProxy)
return "";
QString fileName = UBPersistenceManager::teacherGuideDirectory + "/" + uuid + "." + fi.suffix();
QString destPath = pDocumentProxy->persistencePath() + "/" + fileName;
if (!QFile::exists(destPath)){
QDir dir;
dir.mkdir(pDocumentProxy->persistencePath() + "/" + UBPersistenceManager::teacherGuideDirectory);
QFile source(pPath);
source.copy(destPath);
}
return destPath;
}
QString UBPersistenceManager::addVideoFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid) QString UBPersistenceManager::addVideoFileToDocument(UBDocumentProxy* pDocumentProxy, QString path, QUuid objectUuid)
{ {

@ -41,11 +41,12 @@ class UBPersistenceManager : public QObject
static const QString videoDirectory; static const QString videoDirectory;
static const QString audioDirectory; static const QString audioDirectory;
static const QString widgetDirectory; static const QString widgetDirectory;
static const QString teacherGuideDirectory;
static UBPersistenceManager* persistenceManager(); static UBPersistenceManager* persistenceManager();
static void destroy(); static void destroy();
virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true); virtual UBDocumentProxy* createDocument(const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = true);
virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false); virtual UBDocumentProxy* createDocumentFromDir(const QString& pDocumentDirectory, const QString& pGroupName = "", const QString& pName = "", bool withEmptyPage = false);
virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy); virtual UBDocumentProxy* persistDocumentMetadata(UBDocumentProxy* pDocumentProxy);
@ -80,6 +81,9 @@ class UBPersistenceManager : public QObject
virtual QString generateUniqueDocumentPath(); virtual QString generateUniqueDocumentPath();
QString teacherGuideAbsoluteObjectPath(UBDocumentProxy* pDocumentProxy);
QString addObjectToTeacherGuideDirectory(UBDocumentProxy* proxy, QString pPath);
virtual void addDirectoryContentToDocument(const QString& documentRootFolder, UBDocumentProxy* pDocument); virtual void addDirectoryContentToDocument(const QString& documentRootFolder, UBDocumentProxy* pDocument);
virtual void upgradeDocumentIfNeeded(UBDocumentProxy* pDocumentProxy); virtual void upgradeDocumentIfNeeded(UBDocumentProxy* pDocumentProxy);

@ -113,7 +113,7 @@ void UBDocumentNavigator::generateThumbnails()
{ {
QPixmap pix = thumbs.at(i); QPixmap pix = thumbs.at(i);
QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailNavigPixmap(pix, mCrntDoc, i); QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailNavigPixmap(pix, mCrntDoc, i);
UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(tr("Page %0").arg(i + 1)); UBThumbnailTextItem *labelItem = new UBThumbnailTextItem(tr("Page %0").arg(UBApplication::boardController->pageFromSceneIndex(i)));
UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem); UBImgTextThumbnailElement thumbWithText(pixmapItem, labelItem);
thumbWithText.setBorder(border()); thumbWithText.setBorder(border());

@ -33,8 +33,7 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):
{ {
setOrientation(eUBDockOrientation_Left); setOrientation(eUBDockOrientation_Left);
setMaximumWidth(300); setMaximumWidth(300);
//mCollapsedIcon = QPixmap(":images/pages_open.png");
//mIcon = QPixmap(":images/pages_close.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height()); resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300; mLastWidth = 300;
@ -129,7 +128,7 @@ void UBNavigatorPalette::changeCurrentPage()
if(NO_PAGESELECTED != iPage) if(NO_PAGESELECTED != iPage)
{ {
// Display the selected page // Display the selected page
UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage); UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage);
} }
} }

@ -862,15 +862,19 @@ void UBTeacherGuidePageZeroWidget::loadData()
void UBTeacherGuidePageZeroWidget::persistData() void UBTeacherGuidePageZeroWidget::persistData()
{ {
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); // check necessary because at document closing hide event is send after boardcontroller set
documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text()); // to NULL
documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text()); if(UBApplication::boardController){
documentProxy->setMetaData(UBSettings::sessionGoals,mpGoals->text()); UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument();
documentProxy->setMetaData(UBSettings::sessionKeywords,mpKeywords->text()); documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text());
documentProxy->setMetaData(UBSettings::sessionGradeLevel,mpSchoolLevelBox->currentText()); documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text());
documentProxy->setMetaData(UBSettings::sessionBranch,mpSchoolBranchBox->currentText()); documentProxy->setMetaData(UBSettings::sessionGoals,mpGoals->text());
documentProxy->setMetaData(UBSettings::sessionType,mpSchoolTypeBox->currentText()); documentProxy->setMetaData(UBSettings::sessionKeywords,mpKeywords->text());
documentProxy->setMetaData(UBSettings::sessionLicence,mpLicenceBox->currentText()); documentProxy->setMetaData(UBSettings::sessionGradeLevel,mpSchoolLevelBox->currentText());
documentProxy->setMetaData(UBSettings::sessionBranch,mpSchoolBranchBox->currentText());
documentProxy->setMetaData(UBSettings::sessionType,mpSchoolTypeBox->currentText());
documentProxy->setMetaData(UBSettings::sessionLicence,mpLicenceBox->currentText());
}
} }
void UBTeacherGuidePageZeroWidget::updateSceneTitle() void UBTeacherGuidePageZeroWidget::updateSceneTitle()

@ -855,6 +855,7 @@ 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