Commit 4e884672 authored by unknown's avatar unknown

Merge branch 'master' of github.com:Sankore/Sankore-3.1

parents 622b4d95 076e074e
...@@ -1078,7 +1078,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene() ...@@ -1078,7 +1078,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistCurrentScene()
{ {
if (mCurrentScene != 0 && mCurrentScene->isModified()) if (mCurrentScene != 0 && mCurrentScene->isModified())
{ {
UBThumbnailAdaptor::persistScene(mProxy->persistencePath(), mCurrentScene, mProxy->pageCount() - 1); UBThumbnailAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1);
UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1); UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, mProxy->pageCount() - 1);
mCurrentScene->setModified(false); mCurrentScene->setModified(false);
...@@ -1102,7 +1102,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes() ...@@ -1102,7 +1102,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes()
UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, i); UBSvgSubsetAdaptor::persistScene(mProxy, mCurrentScene, i);
UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i); UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i);
tmpScene->setModified(true); tmpScene->setModified(true);
UBThumbnailAdaptor::persistScene(mProxy->persistencePath(), tmpScene, i); UBThumbnailAdaptor::persistScene(mProxy, tmpScene, i);
delete tmpScene; delete tmpScene;
mCurrentScene->setModified(false); mCurrentScene->setModified(false);
......
...@@ -56,6 +56,8 @@ ...@@ -56,6 +56,8 @@
#include "interfaces/IDataStorage.h" #include "interfaces/IDataStorage.h"
#include "document/UBDocumentContainer.h"
#include "pdf/PDFRenderer.h" #include "pdf/PDFRenderer.h"
#include "core/memcheck.h" #include "core/memcheck.h"
...@@ -313,7 +315,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex) ...@@ -313,7 +315,7 @@ QString UBSvgSubsetAdaptor::readTeacherGuideNode(int sceneIndex)
{ {
QString result; QString result;
QString fileName = UBApplication::boardController->activeDocument()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sceneIndex); QString fileName = UBApplication::boardController->selectedDocument()->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", sceneIndex);
QFile file(fileName); QFile file(fileName);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
QByteArray fileByteArray=file.readAll(); QByteArray fileByteArray=file.readAll();
......
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBTHUMBNAILADAPTOR_H #ifndef UBTHUMBNAILADAPTOR_H
#define UBTHUMBNAILADAPTOR_H #define UBTHUMBNAILADAPTOR_H
#include <QtCore> #include <QtCore>
class UBDocument; class UBDocument;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsScene; class UBGraphicsScene;
class UBThumbnailAdaptor //static class class UBThumbnailAdaptor //static class
{ {
Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor) Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor)
private: UBThumbnailAdaptor() {} public:
public: static QUrl thumbnailUrl(UBDocumentProxy* proxy, int pageIndex);
static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static void persistScene(UBDocumentProxy* proxy, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);
static void generateMissingThumbnails(UBDocumentProxy* proxy);
static QList<QPixmap> load(UBDocumentProxy* proxy); static const QPixmap* get(UBDocumentProxy* proxy, int index);
static QPixmap load(UBDocumentProxy* proxy, int index); static void load(UBDocumentProxy* proxy, QList<const QPixmap*>& list);
static QUrl thumbnailUrl(UBDocumentProxy* proxy, int pageIndex); private:
}; static void generateMissingThumbnails(UBDocumentProxy* proxy);
#endif // UBTHUMBNAILADAPTOR_H UBThumbnailAdaptor() {}
};
#endif // UBTHUMBNAILADAPTOR_H
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTPUBLISHER_H #ifndef UBDOCUMENTPUBLISHER_H
#define UBDOCUMENTPUBLISHER_H #define UBDOCUMENTPUBLISHER_H
#include <QtGui> #include <QtGui>
#include <QtNetwork> #include <QtNetwork>
#include "ui_webPublishing.h" #include "ui_webPublishing.h"
#define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain" #define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain"
typedef struct typedef struct
{ {
QString title; QString title;
QString description; QString description;
} sDocumentInfos; } sDocumentInfos;
class UBDocumentProxy; class UBDocumentProxy;
class UBServerXMLHttpRequest; class UBServerXMLHttpRequest;
class UBGraphicsW3CWidgetItem; class UBGraphicsW3CWidgetItem;
class QWebView; class QWebView;
class UBProxyLoginDlg : public QDialog class UBProxyLoginDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
UBProxyLoginDlg(QWidget* parent=0, const char* name="ProxyLoginDlg"); UBProxyLoginDlg(QWidget* parent=0, const char* name="ProxyLoginDlg");
~UBProxyLoginDlg(); ~UBProxyLoginDlg();
QString username(){return mpUsername->text();} QString username(){return mpUsername->text();}
QString password(){return mpPassword->text();} QString password(){return mpPassword->text();}
private: private:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpUserLayout; QHBoxLayout* mpUserLayout;
QHBoxLayout* mpPasswordLayout; QHBoxLayout* mpPasswordLayout;
QDialogButtonBox* mpButtons; QDialogButtonBox* mpButtons;
QLabel* mpUserLabel; QLabel* mpUserLabel;
QLabel* mpPasswordLabel; QLabel* mpPasswordLabel;
QLineEdit* mpUsername; QLineEdit* mpUsername;
QLineEdit* mpPassword; QLineEdit* mpPassword;
}; };
class UBPublicationDlg : public QDialog class UBPublicationDlg : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
UBPublicationDlg(QWidget* parent=0, const char* name="UBPublicationDlg"); UBPublicationDlg(QWidget* parent=0, const char* name="UBPublicationDlg");
~UBPublicationDlg(); ~UBPublicationDlg();
QString title(){return mpTitle->text();} QString title(){return mpTitle->text();}
QString description(){return mpDescription->document()->toPlainText();} QString description(){return mpDescription->document()->toPlainText();}
private slots: private slots:
void onTextChanged(); void onTextChanged();
private: private:
QVBoxLayout* mpLayout; QVBoxLayout* mpLayout;
QHBoxLayout* mpTitleLayout; QHBoxLayout* mpTitleLayout;
QLabel* mpTitleLabel; QLabel* mpTitleLabel;
QLineEdit* mpTitle; QLineEdit* mpTitle;
QLabel* mpDescLabel; QLabel* mpDescLabel;
QTextEdit* mpDescription; QTextEdit* mpDescription;
QDialogButtonBox* mpButtons; QDialogButtonBox* mpButtons;
}; };
class UBDocumentPublisher : public QObject class UBDocumentPublisher : public QObject
{ {
Q_OBJECT; Q_OBJECT;
public: public:
explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0); explicit UBDocumentPublisher(UBDocumentProxy* sourceDocument, QObject *parent = 0);
virtual ~UBDocumentPublisher(); virtual ~UBDocumentPublisher();
void publish(); void publish();
signals: signals:
void loginDone(); void loginDone();
protected: protected:
virtual void updateGoogleMapApiKey(); virtual void updateGoogleMapApiKey();
virtual void rasterizeScenes(); virtual void rasterizeScenes();
virtual void upgradeDocumentForPublishing(); virtual void upgradeDocumentForPublishing();
virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber); virtual void generateWidgetPropertyScript(UBGraphicsW3CWidgetItem *widgetItem, int pageNumber);
private slots: private slots:
void onFinished(QNetworkReply* reply); void onFinished(QNetworkReply* reply);
private: private:
UBDocumentProxy *mSourceDocument; UBDocumentProxy *mSourceDocument;
UBDocumentProxy *mPublishingDocument;
void init(); //UBDocumentProxy *mPublishingDocument;
void sendUbw(QString username, QString password); QString mPublishingPath;
QString getBase64Of(QString stringToEncode); int mPublishingSize;
QHBoxLayout* mpLayout;
QNetworkAccessManager* mpNetworkMgr; void init();
QNetworkCookieJar* mpCookieJar; void sendUbw(QString username, QString password);
QString mUsername; QString getBase64Of(QString stringToEncode);
QString mPassword;
QString mCrlf; QHBoxLayout* mpLayout;
bool bLoginCookieSet; QNetworkAccessManager* mpNetworkMgr;
QNetworkCookieJar* mpCookieJar;
void buildUbwFile(); QString mUsername;
QString mTmpZipFile; QString mPassword;
QList<QNetworkCookie> mCookies; QString mCrlf;
sDocumentInfos mDocInfos; bool bLoginCookieSet;
}; void buildUbwFile();
#endif // UBDOCUMENTPUBLISHER_H QString mTmpZipFile;
QList<QNetworkCookie> mCookies;
sDocumentInfos mDocInfos;
};
#endif // UBDOCUMENTPUBLISHER_H
...@@ -346,7 +346,7 @@ QString UBWidgetUniboardAPI::pageThumbnail(const int pageNumber) ...@@ -346,7 +346,7 @@ QString UBWidgetUniboardAPI::pageThumbnail(const int pageNumber)
if (UBApplication::boardController->activeScene() != mScene) if (UBApplication::boardController->activeScene() != mScene)
return ""; return "";
UBDocumentProxy *doc = UBApplication::boardController->activeDocument(); UBDocumentProxy *doc = UBApplication::boardController->selectedDocument();
if (!doc) if (!doc)
return ""; return "";
......
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <QtGui> #include <QtGui>
#include <QObject> #include <QObject>
#include "document/UBDocumentContainer.h"
class UBMainWindow; class UBMainWindow;
class UBApplication; class UBApplication;
...@@ -40,7 +41,7 @@ class UBGraphicsWidgetItem; ...@@ -40,7 +41,7 @@ class UBGraphicsWidgetItem;
class UBBoardPaletteManager; class UBBoardPaletteManager;
class UBBoardController : public QObject class UBBoardController : public UBDocumentContainer
{ {
Q_OBJECT Q_OBJECT
...@@ -50,7 +51,7 @@ class UBBoardController : public QObject ...@@ -50,7 +51,7 @@ class UBBoardController : public QObject
void init(); void init();
void setupLayout(); void setupLayout();
UBDocumentProxy* activeDocument() const;
UBGraphicsScene* activeScene() const; UBGraphicsScene* activeScene() const;
int activeSceneIndex() const; int activeSceneIndex() const;
QSize displayViewport(); QSize displayViewport();
...@@ -60,14 +61,6 @@ class UBBoardController : public QObject ...@@ -60,14 +61,6 @@ class UBBoardController : public QObject
int currentPage(); int currentPage();
int pageFromSceneIndex(int sceneIndex);
int sceneIndexFromPage(int page);
UBDocumentProxy* activeDocument()
{
return mActiveDocument;
}
QWidget* controlContainer() QWidget* controlContainer()
{ {
return mControlContainer; return mControlContainer;
...@@ -158,10 +151,17 @@ class UBBoardController : public QObject ...@@ -158,10 +151,17 @@ class UBBoardController : public QObject
void displayMetaData(QMap<QString, QString> metadatas); void displayMetaData(QMap<QString, QString> metadatas);
void ClearUndoStack(); void ClearUndoStack();
void emitScrollSignal() { emit scrollToSelectedPage(); }
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0, bool forceReload = false);
void setActiveDocumentScene(int pSceneIndex);
void moveSceneToIndex(int source, int target);
void duplicateScene(int index);
void deleteScene(int index);
bool cacheIsVisible() {return mCacheWidgetIsEnabled;}
public slots: public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
void showDocumentsDialog(); void showDocumentsDialog();
void showKeyboard(bool show); void showKeyboard(bool show);
void togglePodcast(bool checked); void togglePodcast(bool checked);
...@@ -222,14 +222,12 @@ class UBBoardController : public QObject ...@@ -222,14 +222,12 @@ class UBBoardController : public QObject
void freezeW3CWidget(QGraphicsItem* item, bool freeze); void freezeW3CWidget(QGraphicsItem* item, bool freeze);
void startScript(); void startScript();
void stopScript(); void stopScript();
bool cacheIsVisible();
signals: signals:
void newPageAdded(); void newPageAdded();
void activeSceneWillBePersisted(); void activeSceneWillBePersisted();
void activeSceneWillChange(); void activeSceneWillChange();
void activeSceneChanged(); void activeSceneChanged();
void activeDocumentChanged();
void zoomChanged(qreal pZoomFactor); void zoomChanged(qreal pZoomFactor);
void systemScaleFactorChanged(qreal pSystemScaleFactor); void systemScaleFactorChanged(qreal pSystemScaleFactor);
void penColorChanged(); void penColorChanged();
...@@ -238,10 +236,9 @@ class UBBoardController : public QObject ...@@ -238,10 +236,9 @@ class UBBoardController : public QObject
void cacheEnabled(); void cacheEnabled();
void cacheDisabled(); void cacheDisabled();
void pageChanged(); void pageChanged();
void setDocOnPageNavigator(UBDocumentProxy* doc);
void documentReorganized(int index); void documentReorganized(int index);
void displayMetadata(QMap<QString, QString> metadata); void displayMetadata(QMap<QString, QString> metadata);
void scrollToSelectedPage(); void pageSelectionChanged(int index);
protected: protected:
void setupViews(); void setupViews();
...@@ -263,7 +260,6 @@ class UBBoardController : public QObject ...@@ -263,7 +260,6 @@ class UBBoardController : public QObject
void adjustDisplayViews(); void adjustDisplayViews();
UBMainWindow *mMainWindow; UBMainWindow *mMainWindow;
UBDocumentProxy* mActiveDocument;
UBGraphicsScene* mActiveScene; UBGraphicsScene* mActiveScene;
int mActiveSceneIndex; int mActiveSceneIndex;
UBBoardPaletteManager *mPaletteManager; UBBoardPaletteManager *mPaletteManager;
......
...@@ -134,8 +134,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets() ...@@ -134,8 +134,6 @@ void UBBoardPaletteManager::setupDockPaletteWidgets()
//------------------------------------------------// //------------------------------------------------//
// Create the widgets for the dock palettes // Create the widgets for the dock palettes
mpPageNavigWidget = new UBPageNavigationWidget();
#ifdef USE_WEB_WIDGET #ifdef USE_WEB_WIDGET
mpLibWidget = new UBLibWidget(); mpLibWidget = new UBLibWidget();
#endif #endif
...@@ -352,7 +350,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased() ...@@ -352,7 +350,7 @@ void UBBoardPaletteManager::pagePaletteButtonReleased()
QList<QAction*>pageActions; QList<QAction*>pageActions;
pageActions << UBApplication::mainWindow->actionNewPage; pageActions << UBApplication::mainWindow->actionNewPage;
UBBoardController* boardController = UBApplication::boardController; UBBoardController* boardController = UBApplication::boardController;
if(UBApplication::documentController->pageCanBeDuplicated(boardController->pageFromSceneIndex(boardController->activeSceneIndex()))) if(UBApplication::documentController->pageCanBeDuplicated(UBDocumentContainer::pageFromSceneIndex(boardController->activeSceneIndex())))
pageActions << UBApplication::mainWindow->actionDuplicatePage; pageActions << UBApplication::mainWindow->actionDuplicatePage;
pageActions << UBApplication::mainWindow->actionImportPage; pageActions << UBApplication::mainWindow->actionImportPage;
...@@ -568,7 +566,7 @@ void UBBoardPaletteManager::activeSceneChanged() ...@@ -568,7 +566,7 @@ void UBBoardPaletteManager::activeSceneChanged()
if (mpPageNavigWidget) if (mpPageNavigWidget)
{ {
mpPageNavigWidget->setPageNumber(UBApplication::boardController->pageFromSceneIndex(pageIndex), activeScene->document()->pageCount()); mpPageNavigWidget->setPageNumber(UBDocumentContainer::pageFromSceneIndex(pageIndex), activeScene->document()->pageCount());
} }
if (mZoomPalette) if (mZoomPalette)
......
...@@ -562,7 +562,7 @@ void UBLibraryController::removeBackground() ...@@ -562,7 +562,7 @@ void UBLibraryController::removeBackground()
UBGraphicsScene* UBLibraryController::activeScene() UBGraphicsScene* UBLibraryController::activeScene()
{ {
if (mBoardController->activeDocument()) if (mBoardController->selectedDocument())
return mBoardController->activeScene(); return mBoardController->activeScene();
return 0; return 0;
......
...@@ -317,8 +317,6 @@ int UBApplication::exec(const QString& pFileToImport) ...@@ -317,8 +317,6 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized())); connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized()));
#endif #endif
connect(documentController, SIGNAL(movedToIndex(int)), boardController, SIGNAL(documentReorganized(int)));
mPreferencesController = new UBPreferencesController(mainWindow); mPreferencesController = new UBPreferencesController(mainWindow);
connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show()));
......
...@@ -340,8 +340,7 @@ void UBApplicationController::showBoard() ...@@ -340,8 +340,7 @@ void UBApplicationController::showBoard()
int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex(); int selectedSceneIndex = UBApplication::documentController->getSelectedItemIndex();
if (selectedSceneIndex != -1) if (selectedSceneIndex != -1)
{ {
UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->getCurrentDocument(), selectedSceneIndex); UBApplication::boardController->setActiveDocumentScene(UBApplication::documentController->selectedDocument(), selectedSceneIndex, true);
UBApplication::boardController->emitScrollSignal();
} }
} }
......
...@@ -608,10 +608,10 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy, ...@@ -608,10 +608,10 @@ void UBPersistenceManager::persistDocumentScene(UBDocumentProxy* pDocumentProxy,
if (pScene->isModified()) if (pScene->isModified())
{ {
UBThumbnailAdaptor::persistScene(pDocumentProxy->persistencePath(), pScene, pSceneIndex);
UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex); UBSvgSubsetAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
UBThumbnailAdaptor::persistScene(pDocumentProxy, pScene, pSceneIndex);
pScene->setModified(false); pScene->setModified(false);
} }
......
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBDocumentContainer.h"
#include "adaptors/UBThumbnailAdaptor.h"
#include "core/UBPersistenceManager.h"
#include "core/memcheck.h"
UBDocumentContainer::UBDocumentContainer(QObject * parent)
:QObject(parent)
,mCurrentDocument(NULL)
{}
UBDocumentContainer::~UBDocumentContainer()
{
foreach(const QPixmap* pm, mDocumentThumbs)
delete pm;
}
void UBDocumentContainer::setDocument(UBDocumentProxy* document, bool forceReload)
{
if (mCurrentDocument != document || forceReload)
{
mCurrentDocument = document;
reloadThumbnails();
emit documentSet(mCurrentDocument);
}
}
void UBDocumentContainer::duplicatePages(QList<int>& pageIndexes)
{
int offset = 0;
foreach(int sceneIndex, pageIndexes)
{
UBPersistenceManager::persistenceManager()->duplicateDocumentScene(mCurrentDocument, sceneIndex + offset);
insertThumbPage(sceneIndex + offset);
offset++;
}
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::movePageToIndex(int source, int target)
{
UBPersistenceManager::persistenceManager()->moveSceneToIndex(mCurrentDocument, source, target);
deleteThumbPage(source);
insertThumbPage(target);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::deletePages(QList<int>& pageIndexes)
{
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(mCurrentDocument, pageIndexes);
int offset = 0;
foreach(int index, pageIndexes)
{
deleteThumbPage(index - offset);
offset++;
}
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::addPage(int index)
{
UBPersistenceManager::persistenceManager()->createDocumentSceneAt(mCurrentDocument, index);
insertThumbPage(index);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::updatePage(int index)
{
updateThumbPage(index);
emit documentThumbnailsUpdated(this);
}
void UBDocumentContainer::deleteThumbPage(int index)
{
mDocumentThumbs.removeAt(index);
emit documentPageDeleted(index);
}
void UBDocumentContainer::updateThumbPage(int index)
{
mDocumentThumbs[index] = UBThumbnailAdaptor::get(mCurrentDocument, index);
emit documentPageUpdated(index);
}
void UBDocumentContainer::insertThumbPage(int index)
{
mDocumentThumbs.insert(index, UBThumbnailAdaptor::get(mCurrentDocument, index));
emit documentPageAdded(index);
}
void UBDocumentContainer::reloadThumbnails()
{
if (mCurrentDocument)
{
UBThumbnailAdaptor::load(mCurrentDocument, mDocumentThumbs);
emit documentThumbnailsUpdated(this);
}
}
int UBDocumentContainer::pageFromSceneIndex(int sceneIndex)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return sceneIndex;
return sceneIndex+1;
}
int UBDocumentContainer::sceneIndexFromPage(int page)
{
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool())
return page;
return page-1;
}
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBDOCUMENTCONTAINER_H_
#define UBDOCUMENTCONTAINER_H_
#include <QtGui>
#include "UBDocumentProxy.h"
class UBDocumentContainer : public QObject
{
Q_OBJECT
public:
UBDocumentContainer(QObject * parent = 0);
virtual ~UBDocumentContainer();
void setDocument(UBDocumentProxy* document, bool forceReload = false);
UBDocumentProxy* selectedDocument(){return mCurrentDocument;}
int pageCount(){return mDocumentThumbs.size();}
const QPixmap* pageAt(int index){return mDocumentThumbs[index];}
static int pageFromSceneIndex(int sceneIndex);
static int sceneIndexFromPage(int sceneIndex);
void duplicatePages(QList<int>& pageIndexes);
void movePageToIndex(int source, int target);
void deletePages(QList<int>& pageIndexes);
void addPage(int index);
void updatePage(int index);
private:
void deleteThumbPage(int index);
void updateThumbPage(int index);
void insertThumbPage(int index);
UBDocumentProxy* mCurrentDocument;
QList<const QPixmap*> mDocumentThumbs;
protected:
void reloadThumbnails();
signals:
void documentSet(UBDocumentProxy* document);
void documentPageAdded(int index);
void documentPageDeleted(int index);
void documentPageUpdated(int index);
void documentThumbnailsUpdated(UBDocumentContainer* source);
};
#endif /* UBDOCUMENTPROXY_H_ */
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTCONTROLLER_H_ #ifndef UBDOCUMENTCONTROLLER_H_
#define UBDOCUMENTCONTROLLER_H_ #define UBDOCUMENTCONTROLLER_H_
#include <QtGui> #include <QtGui>
#include "document/UBDocumentContainer.h"
namespace Ui
{ namespace Ui
class documents; {
} class documents;
}
#include "gui/UBMessageWindow.h"
#include "gui/UBMessageWindow.h"
class UBGraphicsScene;
class QDialog; class UBGraphicsScene;
class UBDocumentProxy; class QDialog;
class UBBoardController; class UBDocumentProxy;
class UBThumbnailsScene; class UBBoardController;
class UBDocumentGroupTreeItem; class UBThumbnailsScene;
class UBDocumentProxyTreeItem; class UBDocumentGroupTreeItem;
class UBMainWindow; class UBDocumentProxyTreeItem;
class UBDocumentToolsPalette; class UBMainWindow;
class UBDocumentToolsPalette;
class UBDocumentController : public QObject
{ class UBDocumentController : public UBDocumentContainer
Q_OBJECT; {
Q_OBJECT;
public:
UBDocumentController(UBMainWindow* mainWindow); public:
virtual ~UBDocumentController(); UBDocumentController(UBMainWindow* mainWindow);
virtual ~UBDocumentController();
void closing();
QWidget* controlView(); void closing();
UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy); QWidget* controlView();
bool addFileToDocument(UBDocumentProxy* document); UBDocumentProxyTreeItem* findDocument(UBDocumentProxy* proxy);
UBDocumentProxy* getCurrentDocument() { return mCurrentDocument; }; bool addFileToDocument(UBDocumentProxy* document);
void deletePages(QList<QGraphicsItem*> itemsToDelete); void deletePages(QList<QGraphicsItem*> itemsToDelete);
int getSelectedItemIndex(); int getSelectedItemIndex();
bool pageCanBeMovedUp(int page); bool pageCanBeMovedUp(int page);
bool pageCanBeMovedDown(int page); bool pageCanBeMovedDown(int page);
bool pageCanBeDuplicated(int page); bool pageCanBeDuplicated(int page);
bool pageCanBeDeleted(int page); bool pageCanBeDeleted(int page);
signals: signals:
void refreshThumbnails(); //void refreshThumbnails();
void exportDone(); void exportDone();
void movedToIndex(int index); //void movedToIndex(int index);
public slots: public slots:
void createNewDocument(); void createNewDocument();
void createNewDocumentGroup(); void createNewDocumentGroup();
void deleteSelectedItem(); void deleteSelectedItem();
void renameSelectedItem(); void renameSelectedItem();
void openSelectedItem(); void openSelectedItem();
void duplicateSelectedItem(); void duplicateSelectedItem();
void importFile(); void importFile();
void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target); void moveSceneToIndex(UBDocumentProxy* proxy, int source, int target);
void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true); void selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument = true);
void show(); void show();
void hide(); void hide();
void showMessage(const QString& message, bool showSpinningWheel); void showMessage(const QString& message, bool showSpinningWheel);
void hideMessage(); void hideMessage();
void toggleDocumentToolsPalette(); void toggleDocumentToolsPalette();
void cut(); void cut();
void copy(); void copy();
void paste(); void paste();
void focusChanged(QWidget *old, QWidget *current); void focusChanged(QWidget *old, QWidget *current);
void reloadThumbs(); //void reloadThumbs();
protected: protected:
virtual void setupViews(); virtual void setupViews();
virtual void setupToolbar(); virtual void setupToolbar();
void setupPalettes(); void setupPalettes();
bool isOKToOpenDocument(UBDocumentProxy* proxy); bool isOKToOpenDocument(UBDocumentProxy* proxy);
UBGraphicsScene* activeScene(); UBDocumentProxy* selectedDocumentProxy();
UBDocumentProxy* selectedDocumentProxy(); UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem();
UBDocumentProxyTreeItem* selectedDocumentProxyTreeItem(); UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem();
UBDocumentGroupTreeItem* selectedDocumentGroupTreeItem(); QStringList allGroupNames();
QStringList allGroupNames();
enum LastSelectedElementType
enum LastSelectedElementType {
{ None = 0, Folder, Document, Page
None = 0, Folder, Document, Page };
};
LastSelectedElementType mSelectionType;
LastSelectedElementType mSelectionType;
private:
private: QWidget *mParentWidget;
QWidget *mParentWidget; UBBoardController *mBoardController;
UBBoardController *mBoardController; Ui::documents* mDocumentUI;
Ui::documents* mDocumentUI; UBMainWindow* mMainWindow;
UBMainWindow* mMainWindow; QWidget *mDocumentWidget;
QWidget *mDocumentWidget; QPointer<UBMessageWindow> mMessageWindow;
QPointer<UBMessageWindow> mMessageWindow; QAction* mAddFolderOfImagesAction;
QAction* mAddFolderOfImagesAction; QAction* mAddFileToDocumentAction;
QAction* mAddFileToDocumentAction; QAction* mAddImagesAction;
QAction* mAddImagesAction; bool mIsClosing;
bool mIsClosing; UBDocumentToolsPalette *mToolsPalette;
UBDocumentToolsPalette *mToolsPalette; bool mToolsPalettePositionned;
bool mToolsPalettePositionned; UBDocumentGroupTreeItem* mTrashTi;
UBDocumentGroupTreeItem* mTrashTi;
UBDocumentProxy* mCurrentDocument; private slots:
QList<QPixmap> mDocumentThumbs; void documentZoomSliderValueChanged (int value);
void loadDocumentProxies();
private slots: void itemSelectionChanged();
void documentZoomSliderValueChanged (int value); void exportDocument();
void loadDocumentProxies(); void itemChanged(QTreeWidgetItem * item, int column);
void itemSelectionChanged(); void thumbnailViewResized();
void refreshDocumentThumbnailsView(); void pageSelectionChanged();
void exportDocument(); void selectionChanged();
void itemChanged(QTreeWidgetItem * item, int column); void documentSceneChanged(UBDocumentProxy* proxy, int pSceneIndex);
void thumbnailViewResized(); void pageDoubleClicked(QGraphicsItem* item, int index);
void pageSelectionChanged(); void pageClicked(QGraphicsItem* item, int index);
void selectionChanged(); void itemClicked(QTreeWidgetItem * item, int column );
void documentSceneChanged(UBDocumentProxy* proxy, int pSceneIndex); void addToDocument();
void pageDoubleClicked(QGraphicsItem* item, int index); void addDocumentInTree(UBDocumentProxy* pDocument);
void pageClicked(QGraphicsItem* item, int index); void updateDocumentInTree(UBDocumentProxy* pDocument);
void itemClicked(QTreeWidgetItem * item, int column ); void addFolderOfImages();
void addToDocument(); void addFileToDocument();
void addDocumentInTree(UBDocumentProxy* pDocument); void addImages();
void updateDocumentInTree(UBDocumentProxy* pDocument);
void addFolderOfImages(); void refreshDocumentThumbnailsView(UBDocumentContainer* source);
void addFileToDocument(); };
void addImages();
};
#endif /* UBDOCUMENTCONTROLLER_H_ */
#endif /* UBDOCUMENTCONTROLLER_H_ */
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTPROXY_H_ #ifndef UBDOCUMENTPROXY_H_
#define UBDOCUMENTPROXY_H_ #define UBDOCUMENTPROXY_H_
#include <QtGui> #include <QtGui>
#include "frameworks/UBStringUtils.h" #include "frameworks/UBStringUtils.h"
#include "core/UBSettings.h" #include "core/UBSettings.h"
class UBGraphicsScene; class UBGraphicsScene;
class UBDocumentProxy : public QObject class UBDocumentProxy : public QObject
{ {
Q_OBJECT; Q_OBJECT
public: friend class UBPersistenceManager;
UBDocumentProxy(); public:
UBDocumentProxy(const QString& pPersistencePath);
UBDocumentProxy();
virtual ~UBDocumentProxy(); UBDocumentProxy(const QString& pPersistencePath);
QString persistencePath() const; virtual ~UBDocumentProxy();
void setPersistencePath(const QString& pPersistencePath); QString persistencePath() const;
void setMetaData(const QString& pKey , const QVariant& pValue); void setPersistencePath(const QString& pPersistencePath);
QVariant metaData(const QString& pKey) const;
QHash<QString, QVariant> metaDatas() const; void setMetaData(const QString& pKey , const QVariant& pValue);
QVariant metaData(const QString& pKey) const;
QString name() const; QHash<QString, QVariant> metaDatas() const;
QString groupName() const;
QDateTime documentDate(); QString name() const;
QString groupName() const;
QDateTime lastUpdate(); QDateTime documentDate();
QDateTime lastUpdate();
QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
void setDefaultDocumentSize(int pWidth, int pHeight); QSize defaultDocumentSize() const;
void setDefaultDocumentSize(QSize pSize);
QUuid uuid() const; void setDefaultDocumentSize(int pWidth, int pHeight);
void setUuid(const QUuid& uuid);
QUuid uuid() const;
bool isModified() const; void setUuid(const QUuid& uuid);
int pageCount(); bool isModified() const;
void setPageCount(int pPageCount);
int incPageCount(); int pageCount();
int decPageCount();
protected:
signals: void setPageCount(int pPageCount);
void defaultDocumentSizeChanged(); int incPageCount();
int decPageCount();
private:
signals:
void init(); void defaultDocumentSizeChanged();
QString mPersistencePath; private:
QHash<QString, QVariant> mMetaDatas; void init();
bool mIsModified; QString mPersistencePath;
int mPageCount; QHash<QString, QVariant> mMetaDatas;
}; bool mIsModified;
inline bool operator==(const UBDocumentProxy &proxy1, const UBDocumentProxy &proxy2) int mPageCount;
{
return proxy1.persistencePath() == proxy2.persistencePath(); };
}
inline bool operator==(const UBDocumentProxy &proxy1, const UBDocumentProxy &proxy2)
inline uint qHash(const UBDocumentProxy &key) {
{ return proxy1.persistencePath() == proxy2.persistencePath();
return qHash(key.persistencePath()); }
}
inline uint qHash(const UBDocumentProxy &key)
{
#endif /* UBDOCUMENTPROXY_H_ */ return qHash(key.persistencePath());
}
#endif /* UBDOCUMENTPROXY_H_ */
HEADERS += src/document/UBDocumentController.h \ HEADERS += src/document/UBDocumentController.h \
src/document/UBDocumentContainer.h \
src/document/UBDocumentProxy.h src/document/UBDocumentProxy.h
SOURCES += src/document/UBDocumentController.cpp \ SOURCES += src/document/UBDocumentController.cpp \
src/document/UBDocumentContainer.cpp \
src/document/UBDocumentProxy.cpp src/document/UBDocumentProxy.cpp
\ No newline at end of file
...@@ -142,8 +142,8 @@ void UBGraphicsMediaItem::clearSource() ...@@ -142,8 +142,8 @@ void UBGraphicsMediaItem::clearSource()
{ {
QString path = mediaFileUrl().toLocalFile(); QString path = mediaFileUrl().toLocalFile();
//if path is absolute clean duplicated path string //if path is absolute clean duplicated path string
if (!path.contains(UBApplication::boardController->activeDocument()->persistencePath())) if (!path.contains(UBApplication::boardController->selectedDocument()->persistencePath()))
path = UBApplication::boardController->activeDocument()->persistencePath() + "/" + path; path = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + path;
if (!UBFileSystemUtils::deleteFile(path)) if (!UBFileSystemUtils::deleteFile(path))
qDebug() << "cannot delete file: " << path; qDebug() << "cannot delete file: " << path;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "document/UBDocumentContainer.h"
#include "globals/UBGlobals.h" #include "globals/UBGlobals.h"
...@@ -334,7 +335,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath) ...@@ -334,7 +335,7 @@ QString UBFileSystemUtils::normalizeFilePath(const QString& pFilePath)
QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit) QString UBFileSystemUtils::digitFileFormat(const QString& s, int digit)
{ {
int pageDigit = UBApplication::boardController->pageFromSceneIndex(digit); int pageDigit = UBDocumentContainer::pageFromSceneIndex(digit);
return s.arg(pageDigit, 3, 10, QLatin1Char('0')); return s.arg(pageDigit, 3, 10, QLatin1Char('0'));
} }
......
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBDOCUMENTNAVIGATOR_H #ifndef UBDOCUMENTNAVIGATOR_H
#define UBDOCUMENTNAVIGATOR_H #define UBDOCUMENTNAVIGATOR_H
#include <QResizeEvent> #include <QResizeEvent>
#include <QGraphicsView> #include <QGraphicsView>
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QMouseEvent> #include <QMouseEvent>
#include <QThread> #include <QThread>
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "UBThumbnailWidget.h" #include "document/UBDocumentContainer.h"
#include "UBThumbnailWidget.h"
#define NO_PAGESELECTED -1
#define NO_PAGESELECTED -1
class UBDocumentNavigator : public QGraphicsView
{ class UBDocumentNavigator : public QGraphicsView
Q_OBJECT {
public: Q_OBJECT
UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator"); public:
~UBDocumentNavigator(); UBDocumentNavigator(QWidget* parent=0, const char* name="documentNavigator");
~UBDocumentNavigator();
void setDocument(UBDocumentProxy* document);
void setNbColumns(int nbColumns); void setNbColumns(int nbColumns);
int nbColumns(); int nbColumns();
void setThumbnailMinWidth(int width); void setThumbnailMinWidth(int width);
int thumbnailMinWidth(); int thumbnailMinWidth();
int selectedPageNumber();
UBDocumentProxy* currentDoc(); public slots:
void onScrollToSelectedPage(int index);// { if (mCrntItem) centerOn(mCrntItem); }
signals: void generateThumbnails(UBDocumentContainer* source);
void changeCurrentPage(); void updateSpecificThumbnail(int iPage);
public slots: protected:
void onMovedToIndex(int index); virtual void resizeEvent(QResizeEvent *event);
void onScrollToSelectedPage() { centerOn(mCrntItem); } virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
protected:
virtual void resizeEvent(QResizeEvent *event); private:
virtual void mousePressEvent(QMouseEvent *event);
void refreshScene();
private slots: int border();
void addNewPage();
void onSelectionChanged();
void generateThumbnails(); /** The scene */
QGraphicsScene* mScene;
private: /** The current selected item */
void refreshScene(); //UBSceneThumbnailNavigPixmap* mCrntItem;
void updateSpecificThumbnail(int iPage); /** The list of current thumbnails with labels*/
int border(); QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */
int mNbColumns;
/** The scene */ /** The current thumbnails width */
QGraphicsScene* mScene; int mThumbnailWidth;
/** The current selected item */ /** The current thumbnails minimum width */
UBSceneThumbnailNavigPixmap* mCrntItem; int mThumbnailMinWidth;
/** The current document */ };
UBDocumentProxy* mCrntDoc;
/** The list of current thumbnails with labels*/ #endif // UBDOCUMENTNAVIGATOR_H
QList<UBImgTextThumbnailElement> mThumbsWithLabels;
/** The current number of columns */
int mNbColumns;
/** The current thumbnails width */
int mThumbnailWidth;
/** The current thumbnails minimum width */
int mThumbnailMinWidth;
/** A flag indicating that a thumbnail refresh is in progress */
bool bNavig;
};
#endif // UBDOCUMENTNAVIGATOR_H
This diff is collapsed.
This diff is collapsed.
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or * the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "UBNavigatorPalette.h" #include "UBNavigatorPalette.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
/** /**
* \brief Constructor * \brief Constructor
* @param parent as the parent widget * @param parent as the parent widget
* @param name as the object name * @param name as the object name
*/ */
UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name): UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):
UBDockPalette(eUBDockPaletteType_LEFT, parent, name) UBDockPalette(eUBDockPaletteType_LEFT, parent, name)
, mNavigator(NULL) , mNavigator(NULL)
, mLayout(NULL) , mLayout(NULL)
, mHLayout(NULL) , mHLayout(NULL)
, mPageNbr(NULL) , mPageNbr(NULL)
, mClock(NULL) , mClock(NULL)
{ {
// Build the gui // Build the gui
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin()); mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
setLayout(mLayout); setLayout(mLayout);
mNavigator = new UBDocumentNavigator(this); mNavigator = new UBDocumentNavigator(this);
mNavigator->setStyleSheet(QString("background-color : transparent;")); mNavigator->setStyleSheet(QString("background-color : transparent;"));
mLayout->addWidget(mNavigator, 1); mLayout->addWidget(mNavigator, 1);
mHLayout = new QHBoxLayout(); mHLayout = new QHBoxLayout();
mLayout->addLayout(mHLayout, 0); mLayout->addLayout(mHLayout, 0);
mPageNbr = new QLabel(this); mPageNbr = new QLabel(this);
mClock = new QLabel(this); mClock = new QLabel(this);
mHLayout->addWidget(mPageNbr); mHLayout->addWidget(mPageNbr);
mHLayout->addWidget(mClock); mHLayout->addWidget(mClock);
// Configure the page number indicator // Configure the page number indicator
mPageNbr->setStyleSheet(QString("QLabel { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }")); mPageNbr->setStyleSheet(QString("QLabel { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }"));
setPageNumber(0, 0); setPageNumber(0, 0);
mPageNbr->setAlignment(Qt::AlignHCenter); mPageNbr->setAlignment(Qt::AlignHCenter);
// Configure the clock // Configure the clock
mClock->setStyleSheet(QString("QLabel {color: white; background-color: transparent; text-align: center; font-family: Arial; font-weight: bold; font-size: 20px}")); mClock->setStyleSheet(QString("QLabel {color: white; background-color: transparent; text-align: center; font-family: Arial; font-weight: bold; font-size: 20px}"));
mTimeFormat = QLocale::system().timeFormat(QLocale::ShortFormat); mTimeFormat = QLocale::system().timeFormat(QLocale::ShortFormat);
mClock->setAlignment(Qt::AlignHCenter); mClock->setAlignment(Qt::AlignHCenter);
//strip seconds //strip seconds
mTimeFormat = mTimeFormat.remove(":ss"); mTimeFormat = mTimeFormat.remove(":ss");
mTimeFormat = mTimeFormat.remove(":s"); mTimeFormat = mTimeFormat.remove(":s");
mTimerID = startTimer(1000); mTimerID = startTimer(1000);
connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage())); }
}
/**
/** * \brief Destructor
* \brief Destructor */
*/ UBNavigatorPalette::~UBNavigatorPalette()
UBNavigatorPalette::~UBNavigatorPalette() {
{ killTimer(mTimerID);
killTimer(mTimerID);
if(NULL != mClock)
if(NULL != mClock) {
{ delete mClock;
delete mClock; mClock = NULL;
mClock = NULL; }
} if(NULL != mPageNbr)
if(NULL != mPageNbr) {
{ delete mPageNbr;
delete mPageNbr; mPageNbr = NULL;
mPageNbr = NULL; }
} if(NULL != mHLayout)
if(NULL != mHLayout) {
{ delete mHLayout;
delete mHLayout; mHLayout = NULL;
mHLayout = NULL; }
} if(NULL != mLayout)
if(NULL != mLayout) {
{ delete mLayout;
delete mLayout; mLayout = NULL;
mLayout = NULL; }
} if(NULL != mNavigator)
if(NULL != mNavigator) {
{ delete mNavigator;
delete mNavigator; mNavigator = NULL;
mNavigator = NULL; }
} }
}
/**
/** * \brief Set the current document in the navigator
* \brief Set the current document in the navigator * @param document as the given document
* @param document as the given document */
*/
void UBNavigatorPalette::setDocument(UBDocumentProxy *document) /**
{ * \brief Refresh the thumbnails widget
if(mNavigator->currentDoc() != document) */
{ void UBNavigatorPalette::refresh()
mNavigator->setDocument(document); {
} }
}
/**
/** * \brief Handle the resize event
* \brief Change the current page * @param event as the resize event
*/ */
void UBNavigatorPalette::changeCurrentPage() void UBNavigatorPalette::resizeEvent(QResizeEvent *event)
{ {
// Get the index of the page to display UBDockPalette::resizeEvent(event);
int iPage = mNavigator->selectedPageNumber(); if(NULL != mNavigator)
if(NO_PAGESELECTED != iPage) {
{ mNavigator->setMinimumHeight(height() - 2*border());
// Display the selected page }
UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage); }
}
} void UBNavigatorPalette::timerEvent(QTimerEvent *event)
{
/** Q_UNUSED(event);
* \brief Refresh the thumbnails widget updateTime();
*/ }
void UBNavigatorPalette::refresh()
{ void UBNavigatorPalette::updateTime()
mNavigator->setDocument(UBApplication::boardController->activeDocument()); {
} if (mClock)
{
/** mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat));
* \brief Handle the resize event }
* @param event as the resize event }
*/
void UBNavigatorPalette::resizeEvent(QResizeEvent *event) void UBNavigatorPalette::setPageNumber(int current, int total)
{ {
UBDockPalette::resizeEvent(event); mPageNbr->setText(QString("%1 / %2").arg(current).arg(total));
if(NULL != mNavigator) }
{
mNavigator->setMinimumHeight(height() - 2*border());
}
}
void UBNavigatorPalette::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event);
updateTime();
}
void UBNavigatorPalette::updateTime()
{
if (mClock)
{
mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat));
}
}
void UBNavigatorPalette::setPageNumber(int current, int total)
{
mPageNbr->setText(QString("%1 / %2").arg(current).arg(total));
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -245,7 +245,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged() ...@@ -245,7 +245,7 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged()
cleanData(); cleanData();
load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex())); load(UBSvgSubsetAdaptor::readTeacherGuideNode(UBApplication::boardController->activeSceneIndex()));
mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage)); mpPageNumberLabel->setText(tr("Page: %0").arg(currentPage));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle) if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
} }
...@@ -483,7 +483,7 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged() ...@@ -483,7 +483,7 @@ void UBTeacherGuidePresentationWidget::onActiveSceneChanged()
{ {
cleanData(); cleanData();
mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage())); mpPageNumberLabel->setText(tr("Page: %0").arg(UBApplication::boardController->currentPage()));
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(mpDocumentTitle) if(mpDocumentTitle)
mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpDocumentTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
} }
...@@ -535,9 +535,9 @@ void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data) ...@@ -535,9 +535,9 @@ void UBTeacherGuidePresentationWidget::showData(QVector<tUBGEElementNode*> data)
newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11)));
QString mimeTypeString; QString mimeTypeString;
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString(); mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString();
#else #else
mimeTypeString = UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath"); mimeTypeString = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + element->attributes.value("relativePath");
#endif #endif
newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString); newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString);
newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable); newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
...@@ -882,7 +882,7 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel) ...@@ -882,7 +882,7 @@ void UBTeacherGuidePageZeroWidget::onSchoolLevelChanged(QString schoolLevel)
void UBTeacherGuidePageZeroWidget::onActiveSceneChanged() void UBTeacherGuidePageZeroWidget::onActiveSceneChanged()
{ {
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
if(documentProxy && UBApplication::boardController->currentPage() == 0){ if(documentProxy && UBApplication::boardController->currentPage() == 0){
QDateTime creationDate = documentProxy->documentDate(); QDateTime creationDate = documentProxy->documentDate();
mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate)); mpCreationLabel->setText(tr("Created the:\n") + creationDate.toString(Qt::DefaultLocaleShortDate));
...@@ -901,7 +901,7 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event ) ...@@ -901,7 +901,7 @@ void UBTeacherGuidePageZeroWidget::hideEvent ( QHideEvent * event )
void UBTeacherGuidePageZeroWidget::loadData() void UBTeacherGuidePageZeroWidget::loadData()
{ {
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString()); mpSessionTitle->setText(documentProxy->metaData(UBSettings::sessionTitle).toString());
mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString()); mpAuthors->setText(documentProxy->metaData(UBSettings::sessionAuthors).toString());
mpObjectives->setText(documentProxy->metaData(UBSettings::sessionObjectives).toString()); mpObjectives->setText(documentProxy->metaData(UBSettings::sessionObjectives).toString());
...@@ -925,7 +925,7 @@ void UBTeacherGuidePageZeroWidget::persistData() ...@@ -925,7 +925,7 @@ void UBTeacherGuidePageZeroWidget::persistData()
// check necessary because at document closing hide event is send after boardcontroller set // check necessary because at document closing hide event is send after boardcontroller set
// to NULL // to NULL
if(UBApplication::boardController){ if(UBApplication::boardController){
UBDocumentProxy* documentProxy = UBApplication::boardController->activeDocument(); UBDocumentProxy* documentProxy = UBApplication::boardController->selectedDocument();
documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text()); documentProxy->setMetaData(UBSettings::sessionTitle,mpSessionTitle->text());
documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text()); documentProxy->setMetaData(UBSettings::sessionAuthors, mpAuthors->text());
documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text()); documentProxy->setMetaData(UBSettings::sessionObjectives,mpObjectives->text());
......
...@@ -316,7 +316,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWi ...@@ -316,7 +316,7 @@ UBTGMediaWidget::UBTGMediaWidget(QString mediaPath, QTreeWidgetItem* widget, QWi
, mIsInitializationMode(false) , mIsInitializationMode(false)
{ {
setObjectName(name); setObjectName(name);
mMediaPath = UBApplication::boardController->activeDocument()->persistencePath()+ "/" + mediaPath; mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath()+ "/" + mediaPath;
setAcceptDrops(false); setAcceptDrops(false);
createWorkWidget(); createWorkWidget();
setFixedHeight(200); setFixedHeight(200);
...@@ -340,7 +340,7 @@ void UBTGMediaWidget::initializeWithDom(QDomElement element) ...@@ -340,7 +340,7 @@ void UBTGMediaWidget::initializeWithDom(QDomElement element)
{ {
mIsInitializationMode = true; mIsInitializationMode = true;
setAcceptDrops(false); setAcceptDrops(false);
mMediaPath = UBApplication::boardController->activeDocument()->persistencePath() + "/" + element.attribute("relativePath"); mMediaPath = UBApplication::boardController->selectedDocument()->persistencePath() + "/" + element.attribute("relativePath");
qDebug() << mMediaPath; qDebug() << mMediaPath;
createWorkWidget(); createWorkWidget();
setFixedHeight(200); setFixedHeight(200);
...@@ -377,7 +377,7 @@ tUBGEElementNode* UBTGMediaWidget::saveData() ...@@ -377,7 +377,7 @@ tUBGEElementNode* UBTGMediaWidget::saveData()
return 0; return 0;
tUBGEElementNode* result = new tUBGEElementNode(); tUBGEElementNode* result = new tUBGEElementNode();
QString relativePath = mMediaPath; QString relativePath = mMediaPath;
relativePath = relativePath.replace(UBApplication::boardController->activeDocument()->persistencePath()+"/",""); relativePath = relativePath.replace(UBApplication::boardController->selectedDocument()->persistencePath()+"/","");
result->name = "media"; result->name = "media";
result->attributes.insert("title",mpTitle->text()); result->attributes.insert("title",mpTitle->text());
result->attributes.insert("relativePath",relativePath); result->attributes.insert("relativePath",relativePath);
...@@ -394,7 +394,7 @@ void UBTGMediaWidget::createWorkWidget() ...@@ -394,7 +394,7 @@ void UBTGMediaWidget::createWorkWidget()
{ {
QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath); QString mimeType = UBFileSystemUtils::mimeTypeFromFileName(mMediaPath);
bool setMedia = true; bool setMedia = true;
UBDocumentProxy* proxyDocument = UBApplication::boardController->activeDocument(); UBDocumentProxy* proxyDocument = UBApplication::boardController->selectedDocument();
if(mimeType.contains("audio") || mimeType.contains("video")){ if(mimeType.contains("audio") || mimeType.contains("video")){
mMediaType = mimeType.contains("audio")? "audio":"movie"; mMediaType = mimeType.contains("audio")? "audio":"movie";
mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video); mpMediaWidget = new UBMediaWidget(mimeType.contains("audio")?eMediaType_Audio:eMediaType_Video);
......
This diff is collapsed.
...@@ -400,19 +400,19 @@ class UBThumbnailTextItem : public QGraphicsTextItem ...@@ -400,19 +400,19 @@ class UBThumbnailTextItem : public QGraphicsTextItem
class UBImgTextThumbnailElement class UBImgTextThumbnailElement
{ {
private: private:
QGraphicsItem* thumbnail; UBSceneThumbnailNavigPixmap* thumbnail;
UBThumbnailTextItem* caption; UBThumbnailTextItem* caption;
int border; int border;
public: public:
UBImgTextThumbnailElement(QGraphicsItem* thumb, UBThumbnailTextItem* text): border(0) UBImgTextThumbnailElement(UBSceneThumbnailNavigPixmap* thumb, UBThumbnailTextItem* text): border(0)
{ {
this->thumbnail = thumb; this->thumbnail = thumb;
this->caption = text; this->caption = text;
} }
QGraphicsItem* getThumbnail() const { return this->thumbnail; } UBSceneThumbnailNavigPixmap* getThumbnail() const { return this->thumbnail; }
void setThumbnail(QGraphicsItem* newGItem) { this->thumbnail = newGItem; } void setThumbnail(UBSceneThumbnailNavigPixmap* newGItem) { this->thumbnail = newGItem; }
UBThumbnailTextItem* getCaption() const { return this->caption; } UBThumbnailTextItem* getCaption() const { return this->caption; }
void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; } void setCaption(UBThumbnailTextItem* newcaption) { this->caption = newcaption; }
......
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