diff options
author | Sergey Dubitskiy <sergey.dubitskiy@nokia.com> | 2012-01-17 14:03:32 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-18 00:31:45 +0100 |
commit | 9a015666464762d18a9c736fa61c8d5f7050eb21 (patch) | |
tree | b128e16b5657b93fae5f18a0332d8a8b709b3cd7 | |
parent | 2dd159a9cb0deea7af0a44280c198d3fa97f7a7c (diff) |
QTBUG-23551. Model is copied to the dir where QML is saved.
Change-Id: I18ba1dbb3236b6596f9886b165f93135f761ae89
Reviewed-by: Christopher Ham <christopher.ham@nokia.com>
Reviewed-by: Danny Pope <daniel.pope@nokia.com>
-rw-r--r-- | util/qt3d/modeltweak/quickfile.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/util/qt3d/modeltweak/quickfile.cpp b/util/qt3d/modeltweak/quickfile.cpp index 8c8ad6b1..c6bc7bd5 100644 --- a/util/qt3d/modeltweak/quickfile.cpp +++ b/util/qt3d/modeltweak/quickfile.cpp @@ -39,10 +39,31 @@ QString QuickFile::save() const if (!filename.endsWith(".qml")) filename.append(".qml"); - QString modelFilename = QUrl(_filename).toLocalFile(); - QDir outputDir = QFileInfo(filename).absoluteDir(); - QString relativeFilename = outputDir.relativeFilePath(modelFilename); + + QString modelFilename = QUrl(_filename).toLocalFile(); + QString modelFN = QFileInfo(modelFilename).fileName(); + + QString dstModelLocation = outputDir.path() + QDir::separator() + modelFN; + if (dstModelLocation.compare(modelFilename,Qt::CaseInsensitive) != 0) { + // src and dst model paths are different. + // Copy model file over. + qDebug("Attempting to copy:"); + qDebug(" from: %s",modelFilename.toAscii().constData()); + qDebug(" to : %s",dstModelLocation.toAscii().constData()); + QFile dstModelFile(dstModelLocation); + if (dstModelFile.exists()) { + if (!dstModelFile.remove()) { + qDebug(" failed to remove dst file!"); + } + } + QFile srcModelFile(modelFilename); + if (srcModelFile.copy(dstModelLocation)) { + qDebug(" Model was copied successfully."); + } else { + qDebug(" failed to copy model file !"); + } + } QFile file(filename); @@ -51,7 +72,7 @@ QString QuickFile::save() const if (!file.open(QFile::WriteOnly)) return file.errorString(); - QString dataToWrite = _data.arg(relativeFilename); + QString dataToWrite = _data.arg(modelFN); file.write(dataToWrite.toUtf8()); |