modify path
This commit is contained in:
parent
5a3746b09d
commit
99cfba6437
@ -8,8 +8,12 @@
|
|||||||
#include "entities/Entity.h"
|
#include "entities/Entity.h"
|
||||||
|
|
||||||
|
|
||||||
Component::Component(QObject* parent)
|
Component::Component(Component* parent)
|
||||||
: QObject(parent) {
|
: QObject(parent) {
|
||||||
|
if (nullptr != parent) {
|
||||||
|
owner_ = parent->owner_;
|
||||||
|
}
|
||||||
|
|
||||||
uuid_ = QUuid::createUuid().toString();
|
uuid_ = QUuid::createUuid().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class Component : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Component(QObject* parent = nullptr);
|
explicit Component(Component* parent = nullptr);
|
||||||
virtual ~Component();
|
virtual ~Component();
|
||||||
|
|
||||||
virtual void Serialize(const tinyxml2::XMLElement* element);
|
virtual void Serialize(const tinyxml2::XMLElement* element);
|
||||||
|
@ -28,7 +28,7 @@ void EntitiesManager::OnDestory() {
|
|||||||
);
|
);
|
||||||
for (auto* entity : entities) {
|
for (auto* entity : entities) {
|
||||||
RemoveEntity(entity);
|
RemoveEntity(entity);
|
||||||
delete entity;
|
entity->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,9 +70,9 @@ bool EntitiesManager::Parse(const tinyxml2::XMLElement* element, WorkSpace* work
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* EntitiesManager::Create(const QString& name) {
|
Entity* EntitiesManager::Create(const QString& name) {
|
||||||
if (name == "Entity") {
|
/* if (name == "Entity") {
|
||||||
return new Entity(this);
|
return new Entity(this);
|
||||||
}
|
}*/
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ Entity* EntitiesManager::Create(const tinyxml2::XMLElement* element, Entity* par
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* entity = new Entity(this);
|
Entity* entity = new Entity(workspce);
|
||||||
if (nullptr == entity) {
|
if (nullptr == entity) {
|
||||||
LOG_WARN("create entity failed");
|
LOG_WARN("create entity failed");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -9,8 +9,9 @@
|
|||||||
#include "workspace/WorkSpace.h"
|
#include "workspace/WorkSpace.h"
|
||||||
|
|
||||||
|
|
||||||
Entity::Entity(QObject* parent)
|
Entity::Entity(WorkSpace* workspace)
|
||||||
: QObject(parent) {
|
: QObject(workspace)
|
||||||
|
, workspace_(workspace) {
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class Entity : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Entity(QObject* parent = nullptr);
|
explicit Entity(class WorkSpace* workspace);
|
||||||
explicit Entity(const QString& name, QObject* parent = nullptr);
|
explicit Entity(const QString& name, QObject* parent = nullptr);
|
||||||
~Entity();
|
~Entity();
|
||||||
|
|
||||||
|
@ -108,21 +108,16 @@ void PathComponent::Update(double dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PathComponent::SetPath(const QString& path) {
|
void PathComponent::SetPath(const QString& path) {
|
||||||
|
if (path == path_ || path.isEmpty()) {
|
||||||
|
LOG_INFO("path is the same, file:{}", path.toLocal8Bit().constData());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (nullptr != transformPath_) {
|
if (nullptr != transformPath_) {
|
||||||
transformPath_->deleteLater();
|
transformPath_->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString workPath = GetEntity()->GetWorkspace()->GetDir();
|
const QString workPath = GetEntity()->GetWorkspace()->GetDir();
|
||||||
QFileInfo fileInfo(path);
|
const QString filePath = QString("%1/%2").arg(workPath).arg(path);
|
||||||
const QString filePath = QString("%1/%2").arg(workPath).arg(fileInfo.fileName());
|
|
||||||
if (!FileUtils::CopyFileToPath(path, filePath, true)) {
|
|
||||||
LOG_ERROR("PathComponent::SetPath: Failed to copy file to workspace");
|
|
||||||
QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LOG_INFO("PathComponent::SetPath: {}", workPath.toStdString().c_str());
|
|
||||||
|
|
||||||
|
|
||||||
transformPath_ = TransformPath::LoadFromFile(filePath, this);
|
transformPath_ = TransformPath::LoadFromFile(filePath, this);
|
||||||
path_ = path;
|
path_ = path;
|
||||||
}
|
}
|
||||||
|
@ -96,39 +96,51 @@
|
|||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/ChartPlotMenu.ui" line="28"/>
|
<location filename="../ui/Menu/ChartPlotMenu.ui" line="28"/>
|
||||||
|
<source>Run Simu</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
<source>2D Curver</source>
|
<source>2D Curver</source>
|
||||||
<translation>2D</translation>
|
<translation type="vanished">2D</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/ChartPlotMenu.ui" line="41"/>
|
|
||||||
<source>2D(lg) Curver</source>
|
<source>2D(lg) Curver</source>
|
||||||
<translation>2D(lg)</translation>
|
<translation type="vanished">2D(lg)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Menu/ChartPlotMenu.ui" line="54"/>
|
|
||||||
<source>3D Curver</source>
|
<source>3D Curver</source>
|
||||||
<translation>3D</translation>
|
<translation type="vanished">3D</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>CodeEdtUI</name>
|
<name>CodeEdtUI</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/CodeEdtUI.cpp" line="34"/>
|
<location filename="../ui/Layout/CodeEdtUI.cpp" line="36"/>
|
||||||
<source>&file</source>
|
<source>&file</source>
|
||||||
<translation>文件(&f)</translation>
|
<translation>文件(&f)</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/CodeEdtUI.cpp" line="35"/>
|
<location filename="../ui/Layout/CodeEdtUI.cpp" line="37"/>
|
||||||
<source>&Import the template</source>
|
<source>&Import the Main template</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/CodeEdtUI.cpp" line="36"/>
|
<location filename="../ui/Layout/CodeEdtUI.cpp" line="38"/>
|
||||||
|
<source>&Import the LD template</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/Layout/CodeEdtUI.cpp" line="39"/>
|
||||||
|
<source>&Import the SeekerSim template</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/Layout/CodeEdtUI.cpp" line="40"/>
|
||||||
<source>&save</source>
|
<source>&save</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/Layout/CodeEdtUI.cpp" line="59"/>
|
<location filename="../ui/Layout/CodeEdtUI.cpp" line="68"/>
|
||||||
<source>matlab editor</source>
|
<source>matlab editor</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -475,6 +487,11 @@
|
|||||||
<source>file manager</source>
|
<source>file manager</source>
|
||||||
<translation>文件</translation>
|
<translation>文件</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/MainFrame.cpp" line="112"/>
|
||||||
|
<source>simu manager</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>view manager</source>
|
<source>view manager</source>
|
||||||
<translation type="vanished">视图管理</translation>
|
<translation type="vanished">视图管理</translation>
|
||||||
@ -849,12 +866,12 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QFilePathEdit</name>
|
<name>QFilePathEdit</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="733"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="738"/>
|
||||||
<source>Open File</source>
|
<source>Open File</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="733"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="738"/>
|
||||||
<source>All Files (*)</source>
|
<source>All Files (*)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -900,15 +917,15 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtBoolEdit</name>
|
<name>QtBoolEdit</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="266"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="271"/>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="276"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="281"/>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="301"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="306"/>
|
||||||
<source>True</source>
|
<source>True</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="276"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="281"/>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="301"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="306"/>
|
||||||
<source>False</source>
|
<source>False</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1012,97 +1029,97 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtCursorDatabase</name>
|
<name>QtCursorDatabase</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="55"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="60"/>
|
||||||
<source>Arrow</source>
|
<source>Arrow</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="57"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="62"/>
|
||||||
<source>Up Arrow</source>
|
<source>Up Arrow</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="59"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="64"/>
|
||||||
<source>Cross</source>
|
<source>Cross</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="61"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="66"/>
|
||||||
<source>Wait</source>
|
<source>Wait</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="63"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="68"/>
|
||||||
<source>IBeam</source>
|
<source>IBeam</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="65"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="70"/>
|
||||||
<source>Size Vertical</source>
|
<source>Size Vertical</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="67"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="72"/>
|
||||||
<source>Size Horizontal</source>
|
<source>Size Horizontal</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="69"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="74"/>
|
||||||
<source>Size Backslash</source>
|
<source>Size Backslash</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="71"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="76"/>
|
||||||
<source>Size Slash</source>
|
<source>Size Slash</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="73"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="78"/>
|
||||||
<source>Size All</source>
|
<source>Size All</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="75"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="80"/>
|
||||||
<source>Blank</source>
|
<source>Blank</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="77"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="82"/>
|
||||||
<source>Split Vertical</source>
|
<source>Split Vertical</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="79"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="84"/>
|
||||||
<source>Split Horizontal</source>
|
<source>Split Horizontal</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="81"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="86"/>
|
||||||
<source>Pointing Hand</source>
|
<source>Pointing Hand</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="83"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="88"/>
|
||||||
<source>Forbidden</source>
|
<source>Forbidden</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="85"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="90"/>
|
||||||
<source>Open Hand</source>
|
<source>Open Hand</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="87"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="92"/>
|
||||||
<source>Closed Hand</source>
|
<source>Closed Hand</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="89"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="94"/>
|
||||||
<source>What's This</source>
|
<source>What's This</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="91"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="96"/>
|
||||||
<source>Busy</source>
|
<source>Busy</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1334,12 +1351,12 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtPropertyBrowserUtils</name>
|
<name>QtPropertyBrowserUtils</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="184"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="189"/>
|
||||||
<source>[%1, %2, %3] (%4)</source>
|
<source>[%1, %2, %3] (%4)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="211"/>
|
<location filename="../ui/PropertyBrowser/qtpropertybrowserutils.cpp" line="216"/>
|
||||||
<source>[%1, %2]</source>
|
<source>[%1, %2]</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
@ -1573,6 +1590,14 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>SimuRunMenuClass</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../ui/Menu/SimuRunMenu.ui" line="16"/>
|
||||||
|
<source>SimuRunMenu</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>SurfaceDialog</name>
|
<name>SurfaceDialog</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -47,6 +47,11 @@
|
|||||||
#include <QtWidgets/QMenu>
|
#include <QtWidgets/QMenu>
|
||||||
#include <QtCore/QLocale>
|
#include <QtCore/QLocale>
|
||||||
#include <QtWidgets/QFileDialog>
|
#include <QtWidgets/QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "workspace/WorkSpace.h"
|
||||||
|
#include "workspace/WorkSpaceManager.h"
|
||||||
|
#include "utils/FileUtils.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -733,8 +738,26 @@ void QFilePathEdit::onFileSelect() {
|
|||||||
QString filePath = QFileDialog::getOpenFileName(this, tr("Open File"), m_initialvalue, tr("All Files (*)"));
|
QString filePath = QFileDialog::getOpenFileName(this, tr("Open File"), m_initialvalue, tr("All Files (*)"));
|
||||||
if (!filePath.isEmpty()) {
|
if (!filePath.isEmpty()) {
|
||||||
m_fileName = QFileInfo(filePath).fileName();
|
m_fileName = QFileInfo(filePath).fileName();
|
||||||
m_initialvalue = filePath;
|
WorkSpace* workSpace = WorkSpaceManager::Get().GetCurrent();
|
||||||
m_stringEdit->setText(filePath);
|
dyt_check(nullptr != workSpace);
|
||||||
|
|
||||||
|
const QString workPath = workSpace->GetDir();
|
||||||
|
const QString savePath = QString("%1/%2").arg(workPath).arg(m_fileName);
|
||||||
|
if (FileUtils::IsExist(savePath)) {
|
||||||
|
int ret = QMessageBox::question(this, "question", "File already exists, override it?", QMessageBox::Yes | QMessageBox::No);
|
||||||
|
if (QMessageBox::No == ret) {
|
||||||
|
LOG_INFO("user cancel");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!FileUtils::CopyFileToPath(filePath, filePath, true)) {
|
||||||
|
LOG_ERROR("Failed to copy file to workspace");
|
||||||
|
QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG_INFO("PathComponent::SetPath: {}", workPath.toStdString().c_str());
|
||||||
|
m_initialvalue = m_fileName;
|
||||||
|
m_stringEdit->setText(m_fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool FileUtils::IsExist(const QString& filePath) {
|
||||||
|
return QFile::exists(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
bool FileUtils::CopyFileToPath(const QString& sourceDir, QString toDir, bool coverFileIfExist) {
|
bool FileUtils::CopyFileToPath(const QString& sourceDir, QString toDir, bool coverFileIfExist) {
|
||||||
toDir.replace("\\", "/");
|
toDir.replace("\\", "/");
|
||||||
LOG_INFO("copy file from {} to {}", sourceDir.toStdString(), toDir.toStdString());
|
LOG_INFO("copy file from {} to {}", sourceDir.toStdString(), toDir.toStdString());
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
|
|
||||||
class FileUtils {
|
class FileUtils {
|
||||||
public:
|
public:
|
||||||
|
static bool IsExist(const QString& filePath);
|
||||||
static bool CopyFileToPath(const QString& sourceDir, QString toDir, bool coverFileIfExist);
|
static bool CopyFileToPath(const QString& sourceDir, QString toDir, bool coverFileIfExist);
|
||||||
};
|
};
|
@ -89,7 +89,9 @@ bool WorkSpaceManager::Remove(const QString& name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) {
|
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) {
|
||||||
|
dyt_check(nullptr != scene_);
|
||||||
WorkSpace* workspace = new WorkSpace(this);
|
WorkSpace* workspace = new WorkSpace(this);
|
||||||
|
workspace->SetActiveScene(scene_);
|
||||||
if (!workspace->Load(dyt)) {
|
if (!workspace->Load(dyt)) {
|
||||||
LOG_WARN("load workspace failed");
|
LOG_WARN("load workspace failed");
|
||||||
workspace->deleteLater();
|
workspace->deleteLater();
|
||||||
|
Loading…
Reference in New Issue
Block a user