@@ -373,39 +373,43 @@ bool ObjectTreeViewDefaultModel::dropMimeData(const QMimeData* data, Qt::DropAct
373373 return true ;
374374 }
375375
376- if (!data->hasFormat (OBJECT_EDITOR_ID_MIME_TYPE)) {
377- return false ;
378- }
379-
380- auto originPath = getOriginPathFromMimeData (data);
381- auto mimeDataContainsLocalInstances = originPath == project ()->currentPath ();
382- auto movedItemIDs = decodeMimeData (data);
376+ if (data->hasFormat (OBJECT_EDITOR_ID_MIME_TYPE)) {
377+ auto originPath = getOriginPathFromMimeData (data);
378+ auto mimeDataContainsLocalInstances = originPath == project ()->currentPath ();
379+ auto movedItemIDs = decodeMimeData (data);
383380
384- if (mimeDataContainsLocalInstances) {
385- std::vector<SEditorObject> objs;
386- for (const auto & movedItemID : movedItemIDs) {
387- if (auto childObj = project ()->getInstanceByID (movedItemID.toStdString ())) {
388- objs.emplace_back (childObj);
381+ if (mimeDataContainsLocalInstances) {
382+ std::vector<SEditorObject> objs;
383+ for (const auto & movedItemID : movedItemIDs) {
384+ if (auto childObj = project ()->getInstanceByID (movedItemID.toStdString ())) {
385+ objs.emplace_back (childObj);
386+ }
389387 }
390- }
391388
392- moveScenegraphChildren (objs, indexToSEditorObject (parent), row);
393- } else {
394- auto originCommandInterface = externalProjectStore_->getExternalProjectCommandInterface (originPath);
395- std::vector<SEditorObject> objs;
396- for (const auto & movedItemID : movedItemIDs) {
397- if (auto externalProjectObj = originCommandInterface->project ()->getInstanceByID (movedItemID.toStdString ())) {
398- objs.emplace_back (externalProjectObj);
389+ moveScenegraphChildren (objs, indexToSEditorObject (parent), row);
390+ } else {
391+ auto originCommandInterface = externalProjectStore_->getExternalProjectCommandInterface (originPath);
392+ std::vector<SEditorObject> objs;
393+ for (const auto & movedItemID : movedItemIDs) {
394+ if (auto externalProjectObj = originCommandInterface->project ()->getInstanceByID (movedItemID.toStdString ())) {
395+ objs.emplace_back (externalProjectObj);
396+ }
399397 }
398+ auto serializedObjects = originCommandInterface->copyObjects (objs, true );
399+
400+ auto pressedKeys = QGuiApplication::queryKeyboardModifiers ();
401+ auto pasteAsExtRef = pressedKeys.testFlag (Qt::KeyboardModifier::AltModifier) || indexToTreeNode (parent)->getType () == ObjectTreeNodeType::ExtRefGroup;
402+ pasteObjectAtIndex (parent, pasteAsExtRef, nullptr , serializedObjects);
403+ return true ;
400404 }
401- auto serializedObjects = originCommandInterface->copyObjects (objs, true );
402405
403- auto pressedKeys = QGuiApplication::queryKeyboardModifiers ();
404- auto pasteAsExtRef = pressedKeys.testFlag (Qt::KeyboardModifier::AltModifier) || indexToTreeNode (parent)->getType () == ObjectTreeNodeType::ExtRefGroup;
405- pasteObjectAtIndex (parent, pasteAsExtRef, nullptr , serializedObjects);
406+ } else if (!acceptableFileExtensions_.empty () && !getAcceptableFilesInfo (data).empty ()) {
407+ for (const auto & fileInfo : getAcceptableFilesInfo (data)) {
408+ dropFile (fileInfo, parent);
409+ }
410+ return true ;
406411 }
407-
408- return true ;
412+ return false ;
409413}
410414
411415Qt::ItemFlags ObjectTreeViewDefaultModel::flags (const QModelIndex& index) const {
@@ -530,9 +534,13 @@ SEditorObject ObjectTreeViewDefaultModel::createNewObject(const std::string& typ
530534 return newObj;
531535}
532536
533- SEditorObject ObjectTreeViewDefaultModel::createNewObjectFromFile (const QFileInfo& fileInfo) {
534- object_creator::ObjectCreator objCreator (commandInterface_, acceptLuaModules_, acceptLuaInterfaces_, acceptLuaScripts_);
535- return objCreator.createNewObjectFromFile (fileInfo);
537+ void ObjectTreeViewDefaultModel::dropFile (const QFileInfo& fileInfo, const QModelIndex& parent) {
538+ if (gltfDropOpensAssetImportDialog_ && (fileInfo.suffix ().toLower () == " glb" || fileInfo.suffix ().toLower () == " gltf" )) {
539+ importMeshScenegraph (fileInfo.absoluteFilePath (), parent);
540+ } else {
541+ object_creator::ObjectCreator objCreator (commandInterface_, acceptLuaModules_, acceptLuaInterfaces_, acceptLuaScripts_);
542+ objCreator.createNewObjectFromFile (fileInfo);
543+ }
536544}
537545
538546bool ObjectTreeViewDefaultModel::canCopyAtIndices (const QModelIndexList& indices) const {
@@ -685,7 +693,7 @@ void ObjectTreeViewDefaultModel::importMeshScenegraph(const QString& filePath, c
685693 auto dummyCacheEntry = commandInterface_->meshCache ()->registerFileChangedHandler (absPath, {nullptr , nullptr });
686694 if (auto sceneGraphPtr = commandInterface_->meshCache ()->getMeshScenegraph (absPath)) {
687695 MeshScenegraph sceneGraph{*sceneGraphPtr};
688- auto importStatus = raco::common_widgets::MeshAssetImportDialog (sceneGraph, project ()->featureLevel (), nullptr ).exec ();
696+ auto importStatus = raco::common_widgets::MeshAssetImportDialog (sceneGraph, project ()->featureLevel (), QFileInfo (filePath). fileName (), nullptr ).exec ();
689697 if (importStatus == QDialog::Accepted) {
690698 commandInterface_->insertAssetScenegraph (sceneGraph, absPath, selectedObject);
691699 }
@@ -823,6 +831,10 @@ void ObjectTreeViewDefaultModel::setAcceptLuaInterfaces(bool accept) {
823831 acceptLuaInterfaces_ = accept;
824832}
825833
834+ void ObjectTreeViewDefaultModel::setDropGltfOpensAssetImportDialog (bool flag) {
835+ gltfDropOpensAssetImportDialog_ = flag;
836+ }
837+
826838bool ObjectTreeViewDefaultModel::setData (const QModelIndex& index, const QVariant& value, int role) {
827839 bool success{false };
828840
0 commit comments