2
0
Эх сурвалжийг харах

Add more object search flexibility

nordsoft 2 жил өмнө
parent
commit
4ab203eaae

+ 9 - 7
mapeditor/mainwindow.cpp

@@ -539,19 +539,21 @@ void MainWindow::addGroupIntoCatalog(const std::string & groupName, bool useCust
 				painter.scale(scale, scale);
 				painter.drawImage(QPoint(0, 0), *picture);
 			}
-
+			
+			//create object to extract name
+			std::unique_ptr<CGObjectInstance> temporaryObj(factory->create(templ));
+			QString translated = useCustomName ? QString::fromStdString(temporaryObj->getObjectName().c_str()) : subGroupName;
+			itemType->setText(translated);
+			
 			//add parameters
 			QJsonObject data{{"id", QJsonValue(ID)},
 							 {"subid", QJsonValue(secondaryID)},
 							 {"template", QJsonValue(templateId)},
 							 {"animationEditor", QString::fromStdString(templ->editorAnimationFile.getOriginalName())},
 							 {"animation", QString::fromStdString(templ->animationFile.getOriginalName())},
-							 {"preview", jsonFromPixmap(preview)}};
-			
-			//create object to extract name
-			std::unique_ptr<CGObjectInstance> temporaryObj(factory->create(templ));
-			QString translated = useCustomName ? tr(temporaryObj->getObjectName().c_str()) : subGroupName;
-			itemType->setText(translated);
+							 {"preview", jsonFromPixmap(preview)},
+							 {"typeName", QString::fromStdString(factory->getJsonKey())}
+			};
 
 			//do not have extra level
 			if(singleTemplate)

+ 5 - 1
mapeditor/objectbrowser.cpp

@@ -76,8 +76,12 @@ bool ObjectBrowserProxyModel::filterAcceptsRowText(int source_row, const QModelI
 	auto item = dynamic_cast<QStandardItemModel*>(sourceModel())->itemFromIndex(index);
 	if(!item)
 		return false;
+	
+	auto data = item->data().toJsonObject();
 
-	return (filter.isNull() || filter.isEmpty() || item->text().contains(filter, Qt::CaseInsensitive));
+	return (filter.isNull() || filter.isEmpty()
+			|| item->text().contains(filter, Qt::CaseInsensitive)
+			|| data["typeName"].toString().contains(filter, Qt::CaseInsensitive));
 }
 
 Qt::ItemFlags ObjectBrowserProxyModel::flags(const QModelIndex & index) const