bad workaround for issue 1125

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent ed6f6c48e2
commit 947149eacd
  1. 2
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 1
      src/adaptors/UBThumbnailAdaptor.cpp
  3. 6
      src/core/UBApplication.cpp
  4. 94
      src/core/UBDocumentManager.cpp
  5. 9
      src/core/UBPersistenceManager.cpp
  6. 4
      src/core/main.cpp

@ -238,7 +238,7 @@ QString UBSvgSubsetAdaptor::uniboardDocumentNamespaceUriFromVersion(int mFileVer
UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int pageIndex) UBGraphicsScene* UBSvgSubsetAdaptor::loadScene(UBDocumentProxy* proxy, const int pageIndex)
{ {
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", pageIndex);
qDebug() << fileName;
QFile file(fileName); QFile file(fileName);
if (file.exists()) if (file.exists())

@ -96,7 +96,6 @@ void UBThumbnailAdaptor::updateDocumentToHandleZeroPage(UBDocumentProxy* proxy)
if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){ if(UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", 0); QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", 0);
QFile file(fileName); QFile file(fileName);
qDebug() << fileName;
if(!file.exists()){ if(!file.exists()){
UBPersistenceManager::persistenceManager()->persistDocumentScene(proxy,new UBGraphicsScene(proxy),0); UBPersistenceManager::persistenceManager()->persistDocumentScene(proxy,new UBGraphicsScene(proxy),0);
} }

@ -224,8 +224,7 @@ void UBApplication::setupTranslators(QStringList args)
if(!setLanguage.isEmpty()) if(!setLanguage.isEmpty())
forcedLanguage = setLanguage; forcedLanguage = setLanguage;
} }
QStringList availablesTranslations = UBPlatformUtils::availableTranslations();
QString language(""); QString language("");
if(!forcedLanguage.isEmpty()) if(!forcedLanguage.isEmpty())
@ -362,14 +361,13 @@ int UBApplication::exec(const QString& pFileToImport)
boardController->setupLayout(); boardController->setupLayout();
if (pFileToImport.length() > 0) if (pFileToImport.length() > 0)
{
UBApplication::applicationController->importFile(pFileToImport); UBApplication::applicationController->importFile(pFileToImport);
}
#if defined(Q_WS_MAC) #if defined(Q_WS_MAC)
static AEEventHandlerUPP ub_proc_ae_handlerUPP = AEEventHandlerUPP(ub_appleEventProcessor); static AEEventHandlerUPP ub_proc_ae_handlerUPP = AEEventHandlerUPP(ub_appleEventProcessor);
AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, ub_proc_ae_handlerUPP, SRefCon(UBApplication::applicationController), true); AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, ub_proc_ae_handlerUPP, SRefCon(UBApplication::applicationController), true);
#endif #endif
if (UBSettings::settings()->appStartMode->get() == "Desktop") if (UBSettings::settings()->appStartMode->get() == "Desktop")
applicationController->showDesktop(); applicationController->showDesktop();
else else

@ -149,32 +149,32 @@ UBDocumentProxy* UBDocumentManager::importFile(const QFile& pFile, const QString
UBPageBasedImportAdaptor* importAdaptor = (UBPageBasedImportAdaptor*)adaptor; UBPageBasedImportAdaptor* importAdaptor = (UBPageBasedImportAdaptor*)adaptor;
// Document import procedure..... // Document import procedure.....
QString documentName = QFileInfo(pFile.fileName()).completeBaseName(); QString documentName = QFileInfo(pFile.fileName()).completeBaseName();
document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName); document = UBPersistenceManager::persistenceManager()->createDocument(pGroup, documentName);
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QString filepath = pFile.fileName(); QString filepath = pFile.fileName();
if (importAdaptor->folderToCopy() != "") if (importAdaptor->folderToCopy() != "")
{ {
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, pFile.fileName(), importAdaptor->folderToCopy() , uuid, filepath); bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, pFile.fileName(), importAdaptor->folderToCopy() , uuid, filepath);
if (!b) if (!b)
{ {
UBPersistenceManager::persistenceManager()->deleteDocument(document); UBPersistenceManager::persistenceManager()->deleteDocument(document);
UBApplication::setDisabled(false); UBApplication::setDisabled(false);
return NULL; return NULL;
} }
} }
QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath); QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath);
int nPage = 0; int nPage = 0;
foreach(UBGraphicsItem* page, pages) foreach(UBGraphicsItem* page, pages)
{ {
UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true); UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true);
int pageIndex = document->pageCount(); int pageIndex = document->pageCount();
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex); UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex);
importAdaptor->placeImportedItemToScene(scene, page); importAdaptor->placeImportedItemToScene(scene, page);
UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex); UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex);
} }
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document); UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document);
UBApplication::showMessage(tr("Import successful.")); UBApplication::showMessage(tr("Import successful."));
@ -216,28 +216,28 @@ int UBDocumentManager::addFilesToDocument(UBDocumentProxy* document, QStringList
{ {
UBPageBasedImportAdaptor* importAdaptor = (UBPageBasedImportAdaptor*)adaptor; UBPageBasedImportAdaptor* importAdaptor = (UBPageBasedImportAdaptor*)adaptor;
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QString filepath = file.fileName(); QString filepath = file.fileName();
if (importAdaptor->folderToCopy() != "") if (importAdaptor->folderToCopy() != "")
{ {
bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, file.fileName(), importAdaptor->folderToCopy() , uuid, filepath); bool b = UBPersistenceManager::persistenceManager()->addFileToDocument(document, file.fileName(), importAdaptor->folderToCopy() , uuid, filepath);
if (!b) if (!b)
{ {
continue; continue;
} }
} }
QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath); QList<UBGraphicsItem*> pages = importAdaptor->import(uuid, filepath);
int nPage = 0; int nPage = 0;
foreach(UBGraphicsItem* page, pages) foreach(UBGraphicsItem* page, pages)
{ {
UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true); UBApplication::showMessage(tr("Inserting page %1 of %2").arg(++nPage).arg(pages.size()), true);
int pageIndex = document->pageCount(); int pageIndex = document->pageCount();
UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex); UBGraphicsScene* scene = UBPersistenceManager::persistenceManager()->createDocumentSceneAt(document, pageIndex);
importAdaptor->placeImportedItemToScene(scene, page); importAdaptor->placeImportedItemToScene(scene, page);
UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex); UBPersistenceManager::persistenceManager()->persistDocumentScene(document, scene, pageIndex);
UBApplication::boardController->addEmptyThumbPage(); UBApplication::boardController->addEmptyThumbPage();
} }
UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document); UBPersistenceManager::persistenceManager()->persistDocumentMetadata(document);
UBApplication::showMessage(tr("Import of file %1 successful.").arg(file.fileName())); UBApplication::showMessage(tr("Import of file %1 successful.").arg(file.fileName()));

@ -587,6 +587,15 @@ UBGraphicsScene* UBPersistenceManager::loadDocumentScene(UBDocumentProxy* proxy,
return mSceneCache.value(proxy, sceneIndex); return mSceneCache.value(proxy, sceneIndex);
else { else {
UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, sceneIndex); UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, sceneIndex);
// claudio: this is not a good fix but this code has to be reworked
if(!scene && UBSettings::settings()->teacherGuidePageZeroActivated->get().toBool()){
QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.svg", 0);
QFile file(fileName);
if(!file.exists()){
UBPersistenceManager::persistenceManager()->persistDocumentScene(proxy,new UBGraphicsScene(proxy),0);
}
scene = UBSvgSubsetAdaptor::loadScene(proxy, 0);
}
if (scene) if (scene)
mSceneCache.insert(proxy, sceneIndex, scene); mSceneCache.insert(proxy, sceneIndex, scene);

@ -127,9 +127,9 @@ int main(int argc, char *argv[])
app.initialize(false); app.initialize(false);
QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &app, QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &app, SLOT(handleOpenMessage(const QString&)));
SLOT(handleOpenMessage(const QString&)));
qDebug() << fileToOpen;
int result = app.exec(fileToOpen); int result = app.exec(fileToOpen);
app.cleanup(); app.cleanup();

Loading…
Cancel
Save