removed transition file

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 93b26499e5
commit 3646be9fe4
  1. 1
      Sankore_3.1.pro
  2. 8
      resources/forms/mainWindow.ui
  3. 6
      src/adaptors/UBExportDocument.cpp
  4. 6
      src/adaptors/UBWebPublisher.cpp
  5. 14
      src/core/UBApplication.cpp
  6. 5
      src/core/UBApplication.h
  7. 2
      src/domain/UBGraphicsItemDelegate.cpp
  8. 6
      src/domain/UBGraphicsScene.cpp
  9. 1
      src/frameworks/UBCoreGraphicsScene.cpp
  10. 300
      src/transition/UniboardSankoreTransition.cpp
  11. 80
      src/transition/UniboardSankoreTransition.h
  12. 5
      src/transition/transition.pri

@ -49,7 +49,6 @@ include(src/podcast/podcast.pri)
include(src/tools/tools.pri)
include(src/desktop/desktop.pri)
include(src/web/web.pri)
include(src/transition/transition.pri)
include(src/interfaces/interfaces.pri)
include(src/customWidgets/customWidgets.pri)

@ -1623,14 +1623,6 @@
<string>Ctrl+H</string>
</property>
</action>
<action name="actionImportUniboardDocuments">
<property name="text">
<string>Import Uniboard Documents</string>
</property>
<property name="toolTip">
<string>Import old Sankore or Uniboard documents</string>
</property>
</action>
<action name="actionGroupItems">
<property name="checkable">
<bool>true</bool>

@ -37,8 +37,6 @@ THIRD_PARTY_WARNINGS_DISABLE
#include "quazipfile.h"
THIRD_PARTY_WARNINGS_ENABLE
#include "transition/UniboardSankoreTransition.h"
#include "core/memcheck.h"
UBExportDocument::UBExportDocument(QObject *parent)
@ -78,10 +76,6 @@ void UBExportDocument::persist(UBDocumentProxy* pDocumentProxy)
void UBExportDocument::persistsDocument(UBDocumentProxy* pDocumentProxy, QString filename)
{
UniboardSankoreTransition document;
QString documentPath(pDocumentProxy->persistencePath());
document.checkDocumentDirectory(documentPath);
QuaZip zip(filename);
zip.setFileNameCodec("UTF-8");
if(!zip.open(QuaZip::mdCreate))

@ -27,8 +27,6 @@
#include "adaptors/publishing/UBDocumentPublisher.h"
#include "transition/UniboardSankoreTransition.h"
#include "core/memcheck.h"
UBWebPublisher::UBWebPublisher(QObject *parent)
@ -55,10 +53,6 @@ void UBWebPublisher::persist(UBDocumentProxy* pDocumentProxy)
if (!pDocumentProxy)
return;
UniboardSankoreTransition document;
QString documentPath(pDocumentProxy->persistencePath());
document.checkDocumentDirectory(documentPath);
UBDocumentPublisher* publisher = new UBDocumentPublisher(pDocumentProxy, this); // the publisher will self delete when publication finishes
publisher->publish();

@ -72,7 +72,6 @@ UBApplicationController* UBApplication::applicationController = 0;
UBBoardController* UBApplication::boardController = 0;
UBWebController* UBApplication::webController = 0;
UBDocumentController* UBApplication::documentController = 0;
UniboardSankoreTransition* UBApplication::mUniboardSankoreTransition = 0;
UBMainWindow* UBApplication::mainWindow = 0;
@ -180,9 +179,6 @@ UBApplication::~UBApplication()
delete mainWindow;
mainWindow = 0;
delete mUniboardSankoreTransition;
mUniboardSankoreTransition = 0;
UBPersistenceManager::destroy();
UBDownloadManager::destroy();
@ -365,7 +361,6 @@ int UBApplication::exec(const QString& pFileToImport)
connect(mainWindow->actionMultiScreen, SIGNAL(triggered(bool)), applicationController, SLOT(useMultiScreen(bool)));
connect(mainWindow->actionWidePageSize, SIGNAL(triggered(bool)), boardController, SLOT(setWidePageSize(bool)));
connect(mainWindow->actionRegularPageSize, SIGNAL(triggered(bool)), boardController, SLOT(setRegularPageSize(bool)));
connect(mainWindow->actionImportUniboardDocuments, SIGNAL(triggered()), this, SLOT(importUniboardFiles()));
connect(mainWindow->actionCut, SIGNAL(triggered()), applicationController, SLOT(actionCut()));
connect(mainWindow->actionCopy, SIGNAL(triggered()), applicationController, SLOT(actionCopy()));
@ -399,12 +394,6 @@ void UBApplication::onScreenCountChanged(int newCount)
mainWindow->actionMultiScreen->setEnabled(displayManager.numScreens() > 1);
}
void UBApplication::importUniboardFiles()
{
mUniboardSankoreTransition = new UniboardSankoreTransition();
mUniboardSankoreTransition->documentTransition();
}
#ifdef Q_WS_MAC
void UBApplication::showMinimized()
{
@ -662,14 +651,13 @@ void UBApplication::cleanup()
if (boardController) delete boardController;
if (webController) delete webController;
if (documentController) delete documentController;
if (mUniboardSankoreTransition) delete mUniboardSankoreTransition;
applicationController = NULL;
boardController = NULL;
webController = NULL;
documentController = NULL;
mUniboardSankoreTransition = NULL;
}
void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,

@ -28,8 +28,6 @@
#include "qtsingleapplication.h"
#include "transition/UniboardSankoreTransition.h"
namespace Ui
{
class MainWindow;
@ -66,7 +64,6 @@ class UBApplication : public QtSingleApplication
static UBBoardController* boardController;
static UBWebController* webController;
static UBDocumentController* documentController;
static UniboardSankoreTransition* mUniboardSankoreTransition;
static UBMainWindow* mainWindow;
@ -123,8 +120,6 @@ class UBApplication : public QtSingleApplication
#ifdef Q_WS_MAC
void showMinimized();
#endif
void importUniboardFiles();
void onScreenCountChanged(int newCount);
private:

@ -450,7 +450,9 @@ void UBGraphicsItemDelegate::positionHandles()
foreach(DelegateButton* button, mButtons)
button->hide();
if(mFrame)
mFrame->hide();
if (mToolBarItem)
mToolBarItem->hide();
}

@ -1099,9 +1099,6 @@ void UBGraphicsScene::clearContent(clearCase pCase)
case clearAnnotations :
foreach(QGraphicsItem* item, items()) {
bool isGroup = item->type() == UBGraphicsGroupContainerItem::Type;
bool isStrokesGroup = item->type() == UBGraphicsStrokesGroup::Type;
UBGraphicsGroupContainerItem *itemGroup = item->parentItem()
? qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item->parentItem())
: 0;
@ -1110,6 +1107,9 @@ void UBGraphicsScene::clearContent(clearCase pCase)
continue;
}
bool isGroup = item->type() == UBGraphicsGroupContainerItem::Type;
bool isStrokesGroup = item->type() == UBGraphicsStrokesGroup::Type;
bool shouldDelete = false;
switch (static_cast<int>(pCase)) {
case clearAnnotations :

@ -47,6 +47,7 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene()
if (item->scene() == NULL || item->scene() == this)
{
delete item;
item = NULL;
}
}
}

@ -1,300 +0,0 @@
/*
* Copyright (C) 2012 Webdoc SA
*
* This file is part of Open-Sankoré.
*
* Open-Sankoré 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, version 3 of the License,
* with a specific linking exception for the OpenSSL project's
* "OpenSSL" library (or with modified versions of it that use the
* same license as the "OpenSSL" library).
*
* Open-Sankoré 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 Open-Sankoré. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UniboardSankoreTransition.h"
#include "core/UBSettings.h"
#include "frameworks/UBFileSystemUtils.h"
#include "core/UBApplication.h"
#include "core/UBPersistenceManager.h"
#include "gui/UBMainWindow.h"
#include "core/memcheck.h"
UniboardSankoreTransition::UniboardSankoreTransition(QObject *parent) :
QObject(parent)
, mTransitionDlg(NULL)
, mThread(NULL)
{
mOldSankoreDirectory = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
mUniboardSourceDirectory = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
#if defined(Q_WS_MACX)
mOldSankoreDirectory.replace("Sankore/Sankore 3.1", "Sankore");
mUniboardSourceDirectory.replace("Sankore/Sankore 3.1", "Uniboard");
#else
mUniboardSourceDirectory.replace("Sankore/Sankore 3.1", "Mnemis/Uniboard");
#endif
connect(this, SIGNAL(docAdded(UBDocumentProxy*)), UBPersistenceManager::persistenceManager(), SIGNAL(documentCreated(UBDocumentProxy*)));
}
UniboardSankoreTransition::~UniboardSankoreTransition()
{
if(NULL != mTransitionDlg)
{
delete mTransitionDlg;
mTransitionDlg = NULL;
}
if(mThread){
delete mThread;
mThread = NULL;
}
}
void UniboardSankoreTransition::rollbackDocumentsTransition(QFileInfoList& fileInfoList)
{
QFileInfoList::iterator fileInfo;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end(); fileInfo += 1) {
if (fileInfo->isDir() && fileInfo->fileName().startsWith("Uniboard Document ")){
QString sankoreDocumentName = fileInfo->fileName();
sankoreDocumentName.replace("Uniboard","Sankore");
QString sankoreDocumentDirectoryPath = UBSettings::userDocumentDirectory() + "/" + sankoreDocumentName;
if (QFileInfo(sankoreDocumentDirectoryPath).exists()){
UBFileSystemUtils::deleteDir(sankoreDocumentDirectoryPath);
}
}
}
}
bool UniboardSankoreTransition::checkDocumentDirectory(QString& documentDirectoryPath)
{
bool result = true;
result = updateSankoreHRef(documentDirectoryPath);
QString sankoreWidgetPath = documentDirectoryPath + "/widgets";
result &= updateIndexWidget(sankoreWidgetPath);
return result;
}
void UniboardSankoreTransition::documentTransition()
{
if (QFileInfo(mUniboardSourceDirectory).exists() || QFileInfo(mOldSankoreDirectory).exists()){
QString uniboardDocumentDirectory = mUniboardSourceDirectory + "/document";
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(uniboardDocumentDirectory);
fileInfoList << UBFileSystemUtils::allElementsInDirectory(mOldSankoreDirectory + "/document");
QString backupDirectoryPath = UBFileSystemUtils::normalizeFilePath(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
if (fileInfoList.count() != 0){
mTransitionDlg = new UBUpdateDlg(NULL, fileInfoList.count(), backupDirectoryPath);
connect(mTransitionDlg, SIGNAL(updateFiles()), this, SLOT(startDocumentTransition()));
connect(this, SIGNAL(transitionFinished(bool)), mTransitionDlg, SLOT(onFilesUpdated(bool)));
mTransitionDlg->show();
}
}
else{
UBApplication::mainWindow->information(tr("Import old Uniboard/Sankore documents"), tr("There are no documents that should be imported"));
}
}
void UniboardSankoreTransition::startDocumentTransition()
{
mThread = new UniboardSankoreThread(this);
mThread->start();
connect(this,SIGNAL(transitioningFile(QString)),mTransitionDlg,SLOT(transitioningFile(QString)));
}
bool UniboardSankoreTransition::checkPage(QString& sankorePagePath)
{
QFile file(sankorePagePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
QByteArray documentByteArray = file.readAll();
file.close();
QString sankoreDirectory = sankorePagePath.left(sankorePagePath.indexOf("/page"));
sankoreDirectory = QUrl::fromLocalFile(sankoreDirectory).toString();
QString documentString(documentByteArray);
QRegExp videoRegExp("<video(.*)xlink:href=\"(.*)videos/(.*)/>");
videoRegExp.setMinimal(true);
documentString.replace(videoRegExp,"<video\\1xlink:href=\"videos/\\3/>");
QRegExp audioRegExp("<audio(.*)xlink:href=\"(.*)audios/(.*)/>");
audioRegExp.setMinimal(true);
documentString.replace(audioRegExp,"<audio\\1xlink:href=\"audios/\\3/>");
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
file.write(documentString.toAscii());
file.close();
return true;
}
bool UniboardSankoreTransition::checkWidget(QString& sankoreWidgetIndexPath)
{
QFile file(sankoreWidgetIndexPath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
QByteArray documentByteArray = file.readAll();
file.close();
QString documentString(documentByteArray);
QRegExp swfOriginFilePathRegExp("<param name=\"movie\" value=\"(.*)\">");
swfOriginFilePathRegExp.setMinimal(true);
swfOriginFilePathRegExp.indexIn(documentString);
QString origin = swfOriginFilePathRegExp.cap(1);
if(origin.contains("http://")){
// an url is the source of the swf. The source is kept as is.
return true;
}
//changing the path
QRegExp swfDataPathRegExp("<object(.*)data=\"(.*)interactive content/Web/(.*)\"(.*)>");
swfDataPathRegExp.setMinimal(true);
documentString.replace(swfDataPathRegExp,"<object\\1data=\"\\3\">");
QRegExp swfMoviePathRegExp("<param name=\"movie\" value=\"(.*)interactive content/Web/(.*)\">");
swfMoviePathRegExp.setMinimal(true);
documentString.replace(swfMoviePathRegExp,"<param name=\"movie\" value=\"\\2\">");
//copy the swf on the right place
QRegExp swfFileNameRegExp("<param name=\"movie\" value=\"(.*)\">");
swfFileNameRegExp.setMinimal(true);
swfFileNameRegExp.indexIn(documentString);
QString swfFileName = swfFileNameRegExp.cap(1);
int lastDirectoryLevel = sankoreWidgetIndexPath.lastIndexOf("/");
if (lastDirectoryLevel == -1)
lastDirectoryLevel = sankoreWidgetIndexPath.lastIndexOf("\\");
QString destination(sankoreWidgetIndexPath.left(lastDirectoryLevel) + "/" + swfFileName);
QFile(origin).copy(destination);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
return false;
file.write(documentString.toAscii());
file.close();
return true;
}
bool UniboardSankoreTransition::updateIndexWidget(QString& sankoreWidgetPath)
{
bool result = true;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(sankoreWidgetPath);
QFileInfoList::iterator fileInfo;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) {
if (fileInfo->fileName().endsWith("wgt")){
QString path = fileInfo->absolutePath() + "/" + fileInfo->fileName() + "/index.html";
if (QFile(path).exists())
result = checkWidget(path);
path = fileInfo->absolutePath() + "/" + fileInfo->fileName() + "/index.htm";
if (QFile(path).exists())
result &= checkWidget(path);
}
}
return result;
}
bool UniboardSankoreTransition::updateSankoreHRef(QString& sankoreDocumentPath)
{
bool result = true;
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(sankoreDocumentPath);
QFileInfoList::iterator fileInfo;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) {
if (fileInfo->fileName().endsWith("svg")){
QString path = fileInfo->absolutePath() + "/" + fileInfo->fileName();
result = checkPage(path);
}
}
return result;
}
void UniboardSankoreTransition::executeTransition()
{
bool result = false;
QString backupDestinationPath = mTransitionDlg->backupPath() + "/OldSankoreAndUniboardVersionsBackup";
result = UBFileSystemUtils::copyDir(mUniboardSourceDirectory + "/document", backupDestinationPath);
result &= UBFileSystemUtils::copyDir(mOldSankoreDirectory + "/document", backupDestinationPath);
QString uniboardDocumentDirectory = mUniboardSourceDirectory + "/document";
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(uniboardDocumentDirectory);
fileInfoList.append(UBFileSystemUtils::allElementsInDirectory(mOldSankoreDirectory + "/document"));
QFileInfoList::iterator fileInfo;
QString sankoreDocumentDirectory = UBSettings::userDocumentDirectory();
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) {
if (fileInfo->isDir() && (fileInfo->fileName().startsWith("Uniboard Document ") || fileInfo->fileName().startsWith("Sankore Document "))){
QString sankoreDocumentName = fileInfo->fileName();
emit transitioningFile(sankoreDocumentName);
sankoreDocumentName.replace("Uniboard","Sankore");
QString sankoreDocumentPath = sankoreDocumentDirectory + "/" + sankoreDocumentName;
result = UBFileSystemUtils::copyDir(fileInfo->filePath(),sankoreDocumentPath);
result &= updateSankoreHRef(sankoreDocumentPath);
QString sankoreWidgetPath = sankoreDocumentDirectory + "/" + sankoreDocumentName + "/widgets";
result &= updateIndexWidget(sankoreWidgetPath);
}
}
if (!result){
qWarning() << "The transition has failed";
rollbackDocumentsTransition(fileInfoList);
UBFileSystemUtils::deleteDir(backupDestinationPath);
}
else{
UBFileSystemUtils::deleteDir(mOldSankoreDirectory);
UBFileSystemUtils::deleteDir(mUniboardSourceDirectory);
}
emit transitionFinished(result);
}
UniboardSankoreThread::UniboardSankoreThread(QObject* parent):QThread(parent)
{
}
UniboardSankoreThread::~UniboardSankoreThread()
{
}
void UniboardSankoreThread::run()
{
UniboardSankoreTransition* pTransition = dynamic_cast<UniboardSankoreTransition*>(parent());
pTransition->executeTransition();
}

@ -1,80 +0,0 @@
/*
* Copyright (C) 2012 Webdoc SA
*
* This file is part of Open-Sankoré.
*
* Open-Sankoré 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, version 3 of the License,
* with a specific linking exception for the OpenSSL project's
* "OpenSSL" library (or with modified versions of it that use the
* same license as the "OpenSSL" library).
*
* Open-Sankoré 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 Open-Sankoré. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UNIBOARDSANKORETRANSITION_H
#define UNIBOARDSANKORETRANSITION_H
#include <QObject>
#include <QFileInfo>
#include <QThread>
#include "gui/UBUpdateDlg.h"
#include "document/UBDocumentProxy.h"
class UniboardSankoreThread : public QThread
{
Q_OBJECT
public:
UniboardSankoreThread(QObject* parent = 0);
~UniboardSankoreThread();
void run();
};
class UniboardSankoreTransition : public QObject
{
Q_OBJECT
public:
explicit UniboardSankoreTransition(QObject *parent = 0);
~UniboardSankoreTransition();
bool checkDocumentDirectory(QString& documentDirectoryPath);
void documentTransition();
bool checkPage(QString& sankorePagePath);
bool updateSankoreHRef(QString &sankoreDocumentPath);
bool checkWidget(QString& sankoreWidgetPath);
bool updateIndexWidget(QString& sankoreWidgetPath);
void executeTransition();
private:
void rollbackDocumentsTransition(QFileInfoList& fileInfoList);
UBUpdateDlg* mTransitionDlg;
protected:
QString mUniboardSourceDirectory;
QString mOldSankoreDirectory;
UniboardSankoreThread* mThread;
signals:
void transitionFinished(bool result);
void docAdded(UBDocumentProxy* doc);
void transitioningFile(QString documentName);
private slots:
void startDocumentTransition();
};
#endif // UNIBOARDSANKORETRANSITION_H

@ -1,5 +0,0 @@
HEADERS += src/transition/UniboardSankoreTransition.h
SOURCES += src/transition/UniboardSankoreTransition.cpp
Loading…
Cancel
Save