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

preferencesAboutTextFull
shibakaneki 14 years ago
commit 2d4d6bbc85
  1. 6
      Sankore_3.1.pro
  2. 6
      src/board/UBLibraryController.cpp
  3. 1
      src/board/UBLibraryController.h
  4. 5
      src/core/UBApplication.cpp
  5. 5
      src/core/UBSettings.cpp
  6. 8
      src/frameworks/UBDesktopServices_mac.cpp
  7. 5
      src/frameworks/UBFileSystemUtils.cpp
  8. 7
      src/gui/UBLibActionBar.cpp
  9. 66
      src/transition/UniboardSankoreTransition.cpp
  10. 27
      src/transition/UniboardSankoreTransition.h
  11. 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

@ -83,6 +83,11 @@ UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardControll
} }
bool UBLibraryController::canItemsOnElementBeDeleted(UBLibElement *pElement)
{
return !pElement->path().toLocalFile().startsWith(UBSettings::settings()->uniboardShapeLibraryDirectory());
}
void UBLibraryController::createInternalWidgetItems() void UBLibraryController::createInternalWidgetItems()
{ {
QStringList toolUris = UBToolsManager::manager()->allToolIDs(); QStringList toolUris = UBToolsManager::manager()->allToolIDs();
@ -369,6 +374,7 @@ QList<UBLibElement*> UBLibraryController::listElementsInPath(const QString& pPat
QList<UBLibElement*> UBLibraryController::listElementsInVirtualForlder(UBLibElement* pElement) QList<UBLibElement*> UBLibraryController::listElementsInVirtualForlder(UBLibElement* pElement)
{ {
Q_UNUSED(pElement);
return mFavoriteList; return mFavoriteList;
} }

@ -109,6 +109,7 @@ class UBLibraryController : public QObject
QString favoritePath(); QString favoritePath();
void createNewFolder(QString name, UBLibElement* parentElem); void createNewFolder(QString name, UBLibElement* parentElem);
bool canItemsOnElementBeDeleted(UBLibElement *pElement);
signals: signals:
void dialogClosed(int state); void dialogClosed(int state);

@ -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();
} }

@ -731,8 +731,9 @@ QString UBSettings::uniboardDataDirectory()
// ", defaulting to " + UBDesktopServices::storageLocation(QDesktopServices::DataLocation); // ", defaulting to " + UBDesktopServices::storageLocation(QDesktopServices::DataLocation);
} }
} }
QString qtDataPath = UBFileSystemUtils::normalizeFilePath(UBDesktopServices::storageLocation(QDesktopServices::DataLocation));
return UBDesktopServices::storageLocation(QDesktopServices::DataLocation); qtDataPath.replace("/Sankore 3.1", "");
return qtDataPath;
} }

@ -70,8 +70,7 @@ QString UBDesktopServices::storageLocation(StandardLocation type)
short domain = kOnAppropriateDisk; short domain = kOnAppropriateDisk;
if (QDesktopServices::DataLocation == type if (QDesktopServices::DataLocation == type || QDesktopServices::CacheLocation == type)
|| QDesktopServices::CacheLocation == type)
domain = kUserDomain; domain = kUserDomain;
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
@ -82,9 +81,8 @@ QString UBDesktopServices::storageLocation(StandardLocation type)
QString path = getFullPath(ref); QString path = getFullPath(ref);
if (QDesktopServices::DataLocation == type if (QDesktopServices::DataLocation == type || QDesktopServices::CacheLocation == type)
|| QDesktopServices::CacheLocation == type) path += "/Sankore";
path += "/" + QCoreApplication::applicationName();
return path; return path;
} }

@ -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;

@ -337,7 +337,7 @@ void UBLibActionBar::onSelectionChanged(QList<UBLibElement *> itemList, bool isI
mpFavoriteAction->setEnabled(bEnable); mpFavoriteAction->setEnabled(bEnable);
mpSocialAction->setEnabled(bEnable); mpSocialAction->setEnabled(bEnable);
mpDeleteAction->setEnabled(bEnable); mpDeleteAction->setEnabled(bEnable && libraryController()->canItemsOnElementBeDeleted(itemList.at(0)));
} }
/** /**
@ -397,7 +397,10 @@ void UBLibActionBar::dropEvent(QDropEvent *event)
} }
else if(mpDeleteBtn == pTargetW) else if(mpDeleteBtn == pTargetW)
{ {
onActionTrash(); if(mpDeleteBtn->isEnabled())
{
onActionTrash();
}
} }
else if(mpSocialBtn == pTargetW) else if(mpSocialBtn == pTargetW)
{ {

@ -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", "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