Added new files

preferencesAboutTextFull
Claudio Valerio 14 years ago
parent b7397db519
commit 4eea0597ed
  1. 6
      Sankore_3.1.pro
  2. 5
      src/core/UBApplication.cpp
  3. 5
      src/frameworks/UBFileSystemUtils.cpp
  4. 66
      src/transition/UniboardSankoreTransition.cpp
  5. 27
      src/transition/UniboardSankoreTransition.h
  6. 2
      thirdparty/xpdf/xpdf-3.02/xpdf/Makefile

@ -346,3 +346,9 @@ INSTALLS = UB_ETC \
UB_THIRDPARTY_INTERACTIVE UB_THIRDPARTY_INTERACTIVE
OTHER_FILES += OTHER_FILES +=
HEADERS += \
src/transition/UniboardSankoreTransition.h
SOURCES += \
src/transition/UniboardSankoreTransition.cpp

@ -45,6 +45,8 @@
#include "ui_mainWindow.h" #include "ui_mainWindow.h"
#include "transition/UniboardSankoreTransition.h"
QPointer<QUndoStack> UBApplication::undoStack; QPointer<QUndoStack> UBApplication::undoStack;
UBApplicationController* UBApplication::applicationController = 0; UBApplicationController* UBApplication::applicationController = 0;
@ -297,6 +299,9 @@ int UBApplication::exec(const QString& pFileToImport)
UBLibraryController::preloadFirstOnlineLibrary(); UBLibraryController::preloadFirstOnlineLibrary();
UniboardSankoreTransition* transition = new UniboardSankoreTransition();
transition->backupUniboardDirectory();
return QApplication::exec(); return QApplication::exec();
} }

@ -154,8 +154,7 @@ QStringList UBFileSystemUtils::allFiles(const QString& pDirPath)
QFileInfoList UBFileSystemUtils::allElementsInDirectory(const QString& pDirPath) QFileInfoList UBFileSystemUtils::allElementsInDirectory(const QString& pDirPath)
{ {
QDir dir = QDir(pDirPath); QDir dir = QDir(pDirPath);
dir.setFilter(QDir::Files | QDir::Dirs | dir.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
QDir::NoDotAndDotDot | QDir::NoSymLinks);
dir.setSorting(QDir::DirsFirst); dir.setSorting(QDir::DirsFirst);
return QFileInfoList(dir.entryInfoList()); return QFileInfoList(dir.entryInfoList());
@ -164,8 +163,6 @@ QFileInfoList UBFileSystemUtils::allElementsInDirectory(const QString& pDirPath)
bool UBFileSystemUtils::deleteDir(const QString& pDirPath) bool UBFileSystemUtils::deleteDir(const QString& pDirPath)
{ {
//qDebug() << "UBFileSystemUtils::deleteDir.start" << pDirPath;
if (pDirPath == "" || pDirPath == "." || pDirPath == "..") if (pDirPath == "" || pDirPath == "." || pDirPath == "..")
return false; return false;

@ -0,0 +1,66 @@
#include "UniboardSankoreTransition.h"
#include "core/UBSettings.h"
#include "frameworks/UBDesktopServices.h"
#include "frameworks/UBFileSystemUtils.h"
UniboardSankoreTransition::UniboardSankoreTransition(QObject *parent) :
QObject(parent)
{
mUniboardSourceDirectory = UBDesktopServices::storageLocation(QDesktopServices::DataLocation);
mUniboardSourceDirectory.replace("Sankore/Sankore 3.1", "Mnemis/Uniboard");
}
bool UniboardSankoreTransition::backupUniboardDirectory()
{
bool result = false;
QString destinationDirectory = UBDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
if(QFileInfo(destinationDirectory).exists() && QFileInfo(mUniboardSourceDirectory).exists()){
if(!destinationDirectory.endsWith("/")) destinationDirectory += "/";
result = UBFileSystemUtils::copyDir(mUniboardSourceDirectory, destinationDirectory + QFileInfo(mUniboardSourceDirectory).fileName() + "BackupData/");
if(result) documentTransition();
}
return result;
}
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::uniboardDocumentDirectory() + "/" + sankoreDocumentName;
if (QFileInfo(sankoreDocumentDirectoryPath).exists()){
UBFileSystemUtils::deleteDir(sankoreDocumentDirectoryPath);
}
}
}
}
void UniboardSankoreTransition::documentTransition()
{
QString uniboardDocumentDirectory = mUniboardSourceDirectory + "/document";
QString sankoreDocumentDirectory = UBSettings::uniboardDocumentDirectory();
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(uniboardDocumentDirectory);
QFileInfoList::iterator fileInfo;
bool result = true;
for (fileInfo = fileInfoList.begin(); fileInfo != fileInfoList.end() && result; fileInfo += 1) {
if (fileInfo->isDir() && fileInfo->fileName().startsWith("Uniboard Document ")){
QString sankoreDocumentName = fileInfo->fileName();
sankoreDocumentName.replace("Uniboard","Sankore");
result = UBFileSystemUtils::copyDir(fileInfo->filePath(),sankoreDocumentDirectory + "/" + sankoreDocumentName);
}
}
if (!result){
qWarning() << "The transaction has failed during the copy of the " + fileInfo->filePath() + " document.";
rollbackDocumentsTransition(fileInfoList);
}
else {
UBFileSystemUtils::deleteDir(mUniboardSourceDirectory);
}
}

@ -0,0 +1,27 @@
#ifndef UNIBOARDSANKORETRANSITION_H
#define UNIBOARDSANKORETRANSITION_H
#include <QObject>
#include <QFileInfo>
class UniboardSankoreTransition : public QObject
{
Q_OBJECT
public:
explicit UniboardSankoreTransition(QObject *parent = 0);
bool backupUniboardDirectory();
void documentTransition();
private:
void rollbackDocumentsTransition(QFileInfoList& fileInfoList);
protected:
QString mUniboardSourceDirectory;
signals:
public slots:
};
#endif // UNIBOARDSANKORETRANSITION_H

@ -26,7 +26,7 @@ LDFLAGS =
T1LIBS = T1LIBS =
FTLIBS = FTLIBS =
XLIBS = -lX11 XLIBS = -lXt -lXext -lSM -lICE -lX11
SPLASHLIBS = -L$(SPLASHLIBDIR) -lsplash SPLASHLIBS = -L$(SPLASHLIBDIR) -lsplash

Loading…
Cancel
Save