1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Add more object search flexibility

This commit is contained in:
nordsoft 2023-10-14 03:16:17 +02:00
parent 788147a897
commit 4ab203eaae
2 changed files with 14 additions and 8 deletions

View File

@ -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)

View File

@ -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