summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2018-10-04 10:16:13 +0300
committerMahmoud Badri <mahmoud.badri@qt.io>2018-10-04 09:51:09 +0000
commit4db8200a4e332e781c09685dc7a3cb0bda1a4500 (patch)
treed4d815fb1b7b680b042b0bdcf80adbfdf4aa59a3 /src
parent6e130d0f12ff662f65d77af2e5cb121b966e3536 (diff)
Correct loading initial presentation
Also removed some unused code and minor tweaks. Task-number: QT3DS-2447 Change-Id: I9405879dd2b04df6bdfd6147fbab3e2ede11d4ef Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp15
-rw-r--r--src/Authoring/Studio/Application/ProjectFile.cpp10
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp3
-rw-r--r--src/Authoring/Studio/PreviewHelper.cpp108
-rw-r--r--src/Authoring/Studio/PreviewHelper.h6
-rw-r--r--src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.cpp127
-rw-r--r--src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.h5
7 files changed, 20 insertions, 254 deletions
diff --git a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
index b61a74b8..d7529030 100644
--- a/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
+++ b/src/Authoring/Client/Code/Core/Utility/StudioObjectTypes.cpp
@@ -191,11 +191,6 @@ const QString &CStudioObjectTypes::GetNormalIconName(EStudioObjectType inType)
static QString theString = QStringLiteral("qml_used.png");
return theString;
}
- case OBJTYPE_PROJECT: {
- // Mahmoud_TODO: get a project icon from UX and replace this temp. one
- static QString theString = QStringLiteral("qml_used.png");
- return theString;
- }
default: {
static QString theString = QStringLiteral("Objects-Model-Normal.png");
return theString;
@@ -293,11 +288,6 @@ const QString &CStudioObjectTypes::GetDisabledIconName(EStudioObjectType inType)
static QString theString = QStringLiteral("qml_notUsed.png");
return theString;
}
- case OBJTYPE_PROJECT: {
- // Mahmoud_TODO: get a project icon from UX and replace this temp. one
- static QString theString = QStringLiteral("qml_notUsed.png");
- return theString;
- }
default: {
static QString theString = QStringLiteral("Objects-Model-Disabled.png");
return theString;
@@ -387,11 +377,6 @@ const QString &CStudioObjectTypes::GetHighlightIconName(EStudioObjectType inType
static QString theString = QStringLiteral("presentation_used.png");
return theString;
}
- case OBJTYPE_PROJECT: {
- // Mahmoud_TODO: ask UX to provide a project icon and replace it
- static QString theString = QStringLiteral("qml_used.png");
- return theString;
- }
default: {
static QString theString = QStringLiteral("Objects-Model-Normal.png");
return theString;
diff --git a/src/Authoring/Studio/Application/ProjectFile.cpp b/src/Authoring/Studio/Application/ProjectFile.cpp
index d2855c02..7e3fb7ee 100644
--- a/src/Authoring/Studio/Application/ProjectFile.cpp
+++ b/src/Authoring/Studio/Application/ProjectFile.cpp
@@ -156,7 +156,7 @@ void ProjectFile::addPresentationNode(const QString &pPath, const QString &pId)
file.close();
}
-// get the src attribute (relative path) to the first presentation in a uia file, if no initial
+// Get the src attribute (relative path) to the initial presentation in a uia file, if no initial
// presentation exists, the first one is returned.
QString ProjectFile::getInitialPresentationSrc(const QString &uiaPath)
{
@@ -172,10 +172,9 @@ QString ProjectFile::getInitialPresentationSrc(const QString &uiaPath)
QString initialId = assetsElem.attribute(QStringLiteral("initial"));
if (!initialId.isEmpty()) {
QDomNodeList pNodes = assetsElem.elementsByTagName(QStringLiteral("presentation"));
- const QString docPresentationId = g_StudioApp.GetCore()->GetDoc()->getPresentationId();
for (int i = 0; i < pNodes.count(); ++i) {
QDomElement pElem = pNodes.at(i).toElement();
- if (pElem.attribute(QStringLiteral("id")) == docPresentationId)
+ if (pElem.attribute(QStringLiteral("id")) == initialId)
return pElem.attribute(QStringLiteral("src"));
if (i == 0)
@@ -395,9 +394,11 @@ QString ProjectFile::createPreview()
g_StudioApp.GetCore()->OnSaveDocument(uipPrvPath, true);
}
+ // if no project file exist (.uia) just return the preview uip path
if (!m_fileInfo.exists())
return uipPrvPath;
+ // create a preview project file
QString prvPath = getProjectFilePath();
prvPath.replace(QLatin1String(".uia"), QLatin1String("_@preview@.uia"));
@@ -412,8 +413,7 @@ QString ProjectFile::createPreview()
QDomElement assetsElem = domDoc.documentElement()
.firstChildElement(QStringLiteral("assets"));
- assetsElem.setAttribute(QStringLiteral("initial"),
- doc->getPresentationId());
+ assetsElem.setAttribute(QStringLiteral("initial"), doc->getPresentationId());
if (doc->IsModified()) {
// Set the preview uip path in the uia file
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
index e5567419..e4c7ce78 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
@@ -1084,9 +1084,6 @@ void Qt3DSDMTimelineItemBinding::OnAddChild(Qt3DSDMInstanceHandle inInstance)
if (theNextChild != 0)
theNextItem = m_TransMgr->GetOrCreate(theNextChild);
-
- // Mahmoud_TODO: remove
-// m_Row->AddChildRow(m_TransMgr->GetOrCreate(inInstance), theNextItem);
}
}
diff --git a/src/Authoring/Studio/PreviewHelper.cpp b/src/Authoring/Studio/PreviewHelper.cpp
index e5014f25..852bb2a7 100644
--- a/src/Authoring/Studio/PreviewHelper.cpp
+++ b/src/Authoring/Studio/PreviewHelper.cpp
@@ -46,53 +46,6 @@
#include "remotedeploymentsender.h"
-static const Q3DStudio::CString previewSuffix("_@preview@");
-static const Q3DStudio::CString uipSuffix(".uip");
-static const Q3DStudio::CString uiaSuffix(".uia");
-
-Q3DStudio::CString CPreviewHelper::GetLaunchFile(const Q3DStudio::CString &inUipPath)
-{
- const bool isPreview = inUipPath.Right(previewSuffix.Length() + uipSuffix.Length())
- .Compare(previewSuffix + uipSuffix);
-
- Q3DStudio::CFilePath theUipPath(inUipPath);
- // Mahmoud_TODO: update to use PresentationFile::findProjectFile()
- Q3DStudio::CString theDir = theUipPath.GetDirectory();
- Q3DStudio::CString theStem = theUipPath.GetFileStem();
- if (isPreview)
- theStem = theStem.Left(theStem.Length() - previewSuffix.Length());
-
- // Check if a corresponding .UIA file actually exists
- theDir.append('/');
- Q3DStudio::CString uiaPath = theDir + theStem + uiaSuffix;
-
- Q3DStudio::CFilePath theUiaPath(uiaPath);
- if (theUiaPath.IsFile()) {
- if (isPreview) {
- // We need to make a preview .uia that points to the preview .uip
- Q3DStudio::CString previewPath = theDir + theStem + previewSuffix + uiaSuffix;
- QFile previewFile(previewPath.toQString());
- QFile origFile(uiaPath.toQString());
- if (previewFile.open(QIODevice::WriteOnly) && origFile.open(QIODevice::ReadOnly)) {
- QByteArray content = origFile.readAll();
- QString origUip = (theStem + uipSuffix).toQString();
- QString previewUip = (theStem + previewSuffix + uipSuffix).toQString();
- content.replace(origUip, previewUip.toUtf8());
- previewFile.write(content);
- previewFile.flush();
- return previewPath;
- } else {
- qCWarning(qt3ds::WARNING) << "Failed to create preview .uia file:"
- << previewPath.toQString();
- return inUipPath;
- }
- }
- return uiaPath;
- } else {
- return inUipPath;
- }
-}
-
//=============================================================================
/**
* Callback for previewing a presentation.
@@ -137,8 +90,7 @@ void CPreviewHelper::PreviewViaConfig(Q3DStudio::CBuildConfiguration *inSelected
CCore *theCore = g_StudioApp.GetCore();
QString prvPath = theCore->getProjectFile().createPreview();
try {
- DoPreviewViaConfig(inSelectedConfig, Q3DStudio::CString::fromQString(prvPath),
- inMode, viewerExeName, project);
+ DoPreviewViaConfig(inSelectedConfig, prvPath, inMode, viewerExeName, project);
} catch (...) {
theCore->GetDispatch()->FireOnProgressEnd();
g_StudioApp.GetDialogs()->DisplaySaveReadOnlyFailed(prvPath);
@@ -202,36 +154,27 @@ QString CPreviewHelper::getViewerFilePath(const QString &exeName)
return viewer;
}
-void CPreviewHelper::cleanupProcess(QProcess *p, QString *pDocStr)
+void CPreviewHelper::cleanupProcess(QProcess *p, QString *docPath)
{
p->disconnect();
- QString preview = previewSuffix.toQString();
- QString uia = preview + uiaSuffix.toQString();
- QString uip = preview + uipSuffix.toQString();
- if (pDocStr->endsWith(uia)) {
- // remove presentation preview (initial)
- QString initialPresentationSrc = ProjectFile::getInitialPresentationSrc(*pDocStr);
- if (!initialPresentationSrc.isEmpty() && initialPresentationSrc
- .endsWith(QLatin1String("_@preview@.uip"))) {
- QString absUipPath = QDir(g_StudioApp.GetCore()->getProjectFile().getProjectPath())
- .absoluteFilePath(initialPresentationSrc);
- QFile(absUipPath).remove();
- }
-
- QFile(*pDocStr).remove(); // remove uia preview
- } else if (pDocStr->endsWith(uip)) {
- QFile(*pDocStr).remove();
+ if (docPath->endsWith(QLatin1String("_@preview@.uia"))) {
+ QString uipPreviewPath = g_StudioApp.GetCore()->GetDoc()->GetDocumentPath()
+ .GetAbsolutePath().toQString().replace(".uip", "_@preview@.uip");
+ QFile(uipPreviewPath).remove(); // remove uip preview (if exists)
+ QFile(*docPath).remove(); // remove uia preview
+ } else if (docPath->endsWith(QLatin1String("_@preview@.uip"))) {
+ QFile(*docPath).remove(); // remove uip preview (if exists)
}
if (p->state() == QProcess::Running) {
p->terminate();
p->waitForFinished(5000); // To avoid warning about deleting a running process
}
p->deleteLater();
- delete pDocStr;
+ delete docPath;
}
void CPreviewHelper::DoPreviewViaConfig(Q3DStudio::CBuildConfiguration * /*inSelectedConfig*/,
- const Q3DStudio::CString &inDocumentFile,
+ const QString &inDocumentFile,
EExecMode inMode, const QString &viewerExeName,
RemoteDeploymentSender *project)
{
@@ -239,13 +182,12 @@ void CPreviewHelper::DoPreviewViaConfig(Q3DStudio::CBuildConfiguration * /*inSel
if (inMode == EXECMODE_DEPLOY) {
Q_ASSERT(project);
- project->streamProject(inDocumentFile.toQString());
+ project->streamProject(inDocumentFile);
} else if (inMode == EXECMODE_PREVIEW
&& CStudioPreferences::GetPreviewProperty("PLATFORM") == "PC") {
// Quick Preview on PC without going via NANT
- Q3DStudio::CString theDocumentFile = CPreviewHelper::GetLaunchFile(inDocumentFile);
QString theCommandStr = getViewerFilePath(viewerExeName);
- QString *pDocStr = new QString(theDocumentFile.toQString());
+ QString *pDocStr = new QString(inDocumentFile);
QProcess *p = new QProcess;
QMetaObject::Connection *connection = new QMetaObject::Connection(
@@ -364,27 +306,3 @@ bool CPreviewHelper::ResolveVariable(Q3DStudio::CBuildConfiguration *inSelectedC
return theHasResolved;
}
-
-/**
- * Gets a file to be previewed based on the current document.
- * If the document is dirty, a temp file based on the current document is used.
- * @param outUsingTempFile indicates if temp file is used
- * @return the document file to be previewed
- */
-Qt3DSFile CPreviewHelper::GetDocumentFile(bool &outUsingTempFile)
-{
- Qt3DSFile result("");
- if (g_StudioApp.GetCore()->GetDoc()->IsModified()) {
- Qt3DSFile document = g_StudioApp.GetCore()->GetDoc()->GetDocumentPath();
- Q3DStudio::CFilePath absPath = document.GetAbsolutePath();
- Q3DStudio::CString dir = absPath.GetDirectory();
- Q3DStudio::CString stem = absPath.GetFileStem();
- dir.append('/');
- result = dir + stem + previewSuffix + uipSuffix;
- outUsingTempFile = true;
- } else {
- result = g_StudioApp.GetCore()->GetDoc()->GetDocumentPath();
- outUsingTempFile = false;
- }
- return result;
-}
diff --git a/src/Authoring/Studio/PreviewHelper.h b/src/Authoring/Studio/PreviewHelper.h
index fb7c9607..19d23cb0 100644
--- a/src/Authoring/Studio/PreviewHelper.h
+++ b/src/Authoring/Studio/PreviewHelper.h
@@ -69,7 +69,7 @@ public:
EExecMode inMode, const QString &viewerExeName,
RemoteDeploymentSender *project = 0);
static void DoPreviewViaConfig(Q3DStudio::CBuildConfiguration *inSelectedConfig,
- const Q3DStudio::CString &inDocumentFile,
+ const QString &inDocumentFile,
EExecMode inMode, const QString &viewerExeName,
RemoteDeploymentSender *project = 0);
static bool viewerExists(const QString &exeName);
@@ -81,10 +81,8 @@ protected:
static bool ResolveVariable(Q3DStudio::CBuildConfiguration *inSelectedConfig,
const Q3DStudio::CString &inDocumentFile,
const Q3DStudio::CString &inVariable, Q3DStudio::CString &outValue);
- static Qt3DSFile GetDocumentFile(bool &outUsingTempFile);
- static Q3DStudio::CString GetLaunchFile(const Q3DStudio::CString &inDocFile);
static QString getViewerFilePath(const QString &exeName);
- static void cleanupProcess(QProcess *p, QString *pDocStr);
+ static void cleanupProcess(QProcess *p, QString *docPath);
};
#endif
diff --git a/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.cpp b/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.cpp
index d5069b7e..cd89d52f 100644
--- a/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.cpp
+++ b/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.cpp
@@ -41,138 +41,11 @@ using namespace qt3ds::foundation;
using namespace qt3ds::state;
using namespace eastl;
-static const int DI_SEC_SZ = 5; // Datainput section length in UIP file
-
-// Mahmoud_TODO: this method is to be removed after updating the subpresentation workflow
-// according to the new design (QT3DS-1569).
-bool IApplication::EnsureApplicationFile(const char *inFullUIPPath,
- const QStringList &parameters,
- bool subpresentations)
-{
- eastl::string directory;
- eastl::string filestem;
- eastl::string extension;
- eastl::string filename;
-
- CFileTools::Split(inFullUIPPath, directory, filestem, extension);
- filename = filestem;
- filename.append(1, '.');
- filename.append(extension);
-
- CFileTools::CreateDir(directory.c_str());
- eastl::vector<eastl::string> dirFiles;
- CFileTools::GetDirectoryEntries(directory, dirFiles);
- eastl::string uiaPath;
-
- for (qt3ds::QT3DSU32 idx = 0, end = dirFiles.size(); idx < end && uiaPath.empty(); ++idx) {
- eastl::string fileExt;
- CFileTools::GetExtension(dirFiles[idx].c_str(), fileExt);
- if (fileExt.comparei("uia") == 0)
- CFileTools::CombineBaseAndRelative(directory.c_str(), dirFiles[idx].c_str(), uiaPath);
- }
-
- if (uiaPath.size()) {
- MallocAllocator allocator;
- NVScopedRefCounted<IStringTable> strTable(IStringTable::CreateStringTable(allocator));
- NVScopedRefCounted<IDOMFactory> domFactory(
- IDOMFactory::CreateDOMFactory(allocator, strTable));
- eastl::pair<SNamespacePairNode *, SDOMElement *> readResult;
- {
- CFileSeekableIOStream theInStream(uiaPath.c_str(), FileReadFlags());
- readResult = CDOMSerializer::Read(*domFactory, theInStream);
- }
- if (readResult.second == NULL) {
- QT3DS_ASSERT(false);
- uiaPath.clear();
- } else {
- eastl::pair<NVScopedRefCounted<IDOMWriter>, NVScopedRefCounted<IDOMReader>> writerData
- = IDOMWriter::CreateDOMWriter(domFactory, *readResult.second, strTable);
- NVScopedRefCounted<IDOMReader> domReader(writerData.second);
- if (!domReader->MoveToFirstChild("assets")) {
- writerData.first->Begin("assets");
- } else {
- if (subpresentations) {
- int pre = domReader->CountChildren("presentation");
- int preq = domReader->CountChildren("presentation-qml");
- if (pre + preq > 0) {
- while (domReader->MoveToFirstChild("presentation"))
- writerData.first->RemoveCurrent();
- while (domReader->MoveToFirstChild("presentation-qml"))
- writerData.first->RemoveCurrent();
- }
-
- // Retain the main presentation as the initial one regardless of the
- // sub-presentation we are editing now
- eastl::string dir;
- eastl::string ext;
- // Parse the main presentation name
- CFileTools::Split(uiaPath.c_str(), dir, filestem, ext);
- filename = filestem;
- filename.append(1, '.');
- filename.append(extension);
-
- writerData.first->Begin("presentation");
- writerData.first->Att("id", filestem.c_str());
- writerData.first->Att("src", filename.c_str());
- writerData.first->End();
- } else {
- int dai = domReader->CountChildren("dataInput");
- if (dai > 0) {
- while (domReader->MoveToFirstChild("dataInput"))
- writerData.first->RemoveCurrent();
- }
- }
- }
-
- if (subpresentations) {
- for (int i = 0; i < parameters.size() / 3; i++) {
- writerData.first->Begin(qPrintable(parameters[3 * i]));
- writerData.first->Att("id", qPrintable(parameters[3 * i + 1]));
- if (parameters[3 * i] == QStringLiteral("presentation"))
- writerData.first->Att("src", qPrintable(parameters[3 * i + 2]));
- else
- writerData.first->Att("args", qPrintable(parameters[3 * i + 2]));
- writerData.first->End();
- }
- } else {
- for (int i = 0; i < parameters.size() / DI_SEC_SZ; i++) {
- writerData.first->Begin("dataInput");
- writerData.first->Att("name", qPrintable(parameters[DI_SEC_SZ * i]));
- writerData.first->Att("type", qPrintable(parameters[DI_SEC_SZ * i + 1]));
- if (QStringLiteral("Ranged Number") == parameters[DI_SEC_SZ * i + 1]) {
- writerData.first->Att("min", qPrintable(parameters[DI_SEC_SZ * i + 2]));
- writerData.first->Att("max", qPrintable(parameters[DI_SEC_SZ * i + 3]));
- } else if (QStringLiteral("Evaluator") == parameters[DI_SEC_SZ * i + 1]) {
- writerData.first->Att("evaluator",
- qPrintable(parameters[DI_SEC_SZ * i + 4]));
- }
- writerData.first->End();
- }
- }
-
- CFileSeekableIOStream theOutStream(uiaPath.c_str(), FileWriteFlags());
- if (theOutStream.IsOpen()) {
- NVDataRef<SNamespacePair> namespacePairs;
- if (readResult.first)
- namespacePairs = toDataRef<SNamespacePair>(*readResult.first);
- CDOMSerializer::WriteXMLHeader(theOutStream);
- CDOMSerializer::Write(allocator, *readResult.second, theOutStream, *strTable,
- namespacePairs, false);
- } else {
- return false;
- }
- }
- }
-
- return true;
-}
-
eastl::string IApplication::GetLaunchFile(const char *inFullUIPPath)
{
eastl::string directory;
eastl::string filestem;
eastl::string extension;
- eastl::string filename;
CFileTools::Split(inFullUIPPath, directory, filestem, extension);
eastl::string uiaPath;
diff --git a/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.h b/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.h
index 20261ec8..3ebe0d4f 100644
--- a/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.h
+++ b/src/Runtime/Source/Qt3DSStateApplication/Application/Qt3DSStateApplication.h
@@ -38,11 +38,6 @@ namespace state {
class IApplication
{
public:
- // Upon creation of this application file, ensure the creation of
- // Returns false if it was unable to write or update the uia file.
- static bool EnsureApplicationFile(const char *inFullUIPPath,
- const QStringList &presentations,
- bool subpresentations);
static eastl::string GetLaunchFile(const char *inFullUIPPath);
};
}