From b253ed5774fed7a3ae18e26638c62a5bb7294888 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2012 17:55:19 +0200 Subject: [PATCH] fixed some path issue on windows --- src/core/UBPersistenceManager.cpp | 9 +++++++-- src/domain/UBW3CWidget.cpp | 7 +++++-- src/gui/UBTeacherGuideWidget.cpp | 8 +++++++- src/gui/UBTeacherGuideWidgetsTools.cpp | 6 +++++- src/gui/UBThumbnailWidget.cpp | 2 +- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/core/UBPersistenceManager.cpp b/src/core/UBPersistenceManager.cpp index 91b1f478..29e0ef71 100644 --- a/src/core/UBPersistenceManager.cpp +++ b/src/core/UBPersistenceManager.cpp @@ -848,7 +848,12 @@ QString UBPersistenceManager::teacherGuideAbsoluteObjectPath(UBDocumentProxy* pD QString UBPersistenceManager::addObjectToTeacherGuideDirectory(UBDocumentProxy* pDocumentProxy, QString pPath) { - QFileInfo fi(pPath.replace("file://","")); + QString path = pPath; + //windows + path.replace("file:///",""); + //others + path.replace("file://",""); + QFileInfo fi(path); QString uuid = QUuid::createUuid(); if (!fi.exists() || !pDocumentProxy) @@ -862,7 +867,7 @@ QString UBPersistenceManager::addObjectToTeacherGuideDirectory(UBDocumentProxy* QDir dir; dir.mkdir(pDocumentProxy->persistencePath() + "/" + UBPersistenceManager::teacherGuideDirectory); - QFile source(pPath); + QFile source(path); source.copy(destPath); } diff --git a/src/domain/UBW3CWidget.cpp b/src/domain/UBW3CWidget.cpp index 9b423322..60c7bc52 100644 --- a/src/domain/UBW3CWidget.cpp +++ b/src/domain/UBW3CWidget.cpp @@ -247,7 +247,9 @@ QString UBW3CWidget::createNPAPIWrapperInDir(const QString& pUrl, const QDir& pD { QString url = pUrl; // if the file name start with file:// it has be removed because QFileInfo doesn't support this form - url = url.replace("file://",""); + // + url = url.replace("file:///",""); + url = url.replace("file://",""); QString name = pName; QFileInfo fi(url); @@ -304,7 +306,8 @@ QString UBW3CWidget::createNPAPIWrapperInDir(const QString& pUrl, const QDir& pD if (fi.exists()){ QString target = widgetLibraryPath + "/" + fi.fileName(); QString source = pUrl; - source.replace("file://",""); + source.replace("file:///",""); + source.replace("file://",""); QFile::copy(source, target); } diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp index 9b6cd010..9121ce0a 100644 --- a/src/gui/UBTeacherGuideWidget.cpp +++ b/src/gui/UBTeacherGuideWidget.cpp @@ -533,7 +533,13 @@ void UBTeacherGuidePresentationWidget::showData(QVector data) newWidgetItem->setText(0,element->attributes.value("title")); newWidgetItem->setData(0,tUBTGTreeWidgetItemRole_HasAnAction,tUBTGActionAssociateOnClickItem_MEDIA); newWidgetItem->setData(0,Qt::FontRole, QVariant(QFont(QApplication::font().family(),11))); - newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")); + QString mimeTypeString; +#ifdef Q_WS_WIN + mimeTypeString = QUrl::fromLocalFile(UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath")).toString(); +#else + mimeTypeString = UBApplication::boardController->activeDocument()->persistencePath()+ "/" + element->attributes.value("relativePath"); +#endif + newWidgetItem->setData(0, TG_USER_ROLE_MIME_TYPE, mimeTypeString); newWidgetItem->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable); mpRootWidgetItem->addChild(newWidgetItem); diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp index bbda8fd1..c7ba3aa1 100644 --- a/src/gui/UBTeacherGuideWidgetsTools.cpp +++ b/src/gui/UBTeacherGuideWidgetsTools.cpp @@ -372,7 +372,7 @@ tUBGEElementNode* UBTGMediaWidget::saveData() tUBGEElementNode* result = new tUBGEElementNode(); QString relativePath = mMediaPath; relativePath = relativePath.replace(UBApplication::boardController->activeDocument()->persistencePath()+"/",""); - result->name = "media"; + result->name = "media"; result->attributes.insert("title",mpTitle->text()); result->attributes.insert("relativePath",relativePath); result->attributes.insert("mediaType",mMediaType); @@ -499,7 +499,11 @@ void UBTGMediaWidget::mousePressEvent(QMouseEvent *event) QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData(); QList urlList; +#ifdef Q_WS_WIN + urlList << QUrl::fromLocalFile(mMediaPath); +#else urlList << QUrl(mMediaPath); +#endif mimeData->setUrls(urlList); drag->setMimeData(mimeData); diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp index 371e8abb..4f22cc42 100644 --- a/src/gui/UBThumbnailWidget.cpp +++ b/src/gui/UBThumbnailWidget.cpp @@ -842,7 +842,7 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState() } } } - if(UBSettings::settings()->teacherGuidePageZeroActivated and sceneIndex()<=1) + if(UBSettings::settings()->teacherGuidePageZeroActivated && sceneIndex()<=1) bCanMoveUp = false; if(bCanDelete || bCanMoveUp || bCanMoveDown)