Material: Replace dynamic_cast with qobject_cast

This commit is contained in:
Kacper Donat
2025-04-07 20:00:08 +02:00
committed by Benjamin Nauck
parent b9c74ef138
commit 6c7c7a747d
4 changed files with 16 additions and 16 deletions

View File

@@ -305,7 +305,7 @@ bool MaterialTreeWidget::findInTree(const QStandardItem& node,
QModelIndex MaterialTreeWidget::findInTree(const QString& uuid)
{
auto model = dynamic_cast<QStandardItemModel*>(m_materialTree->model());
auto model = qobject_cast<QStandardItemModel*>(m_materialTree->model());
auto root = model->invisibleRootItem();
QModelIndex index;
@@ -409,7 +409,7 @@ void MaterialTreeWidget::updateMaterialTree()
_favorites.clear();
_recents.clear();
auto model = dynamic_cast<QStandardItemModel*>(m_materialTree->model());
auto model = qobject_cast<QStandardItemModel*>(m_materialTree->model());
model->clear();
getFavorites();
@@ -539,7 +539,7 @@ void MaterialTreeWidget::fillMaterialTree()
auto param = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Material/TreeWidget/MaterialTree");
auto model = dynamic_cast<QStandardItemModel*>(m_materialTree->model());
auto model = qobject_cast<QStandardItemModel*>(m_materialTree->model());
if (_filterOptions.includeFavorites()) {
auto lib = new QStandardItem(tr("Favorites"));
@@ -689,7 +689,7 @@ void MaterialTreeWidget::onSelectMaterial(const QItemSelection& selected,
// Get the UUID before changing the underlying data model
QString uuid;
auto model = dynamic_cast<QStandardItemModel*>(m_materialTree->model());
auto model = qobject_cast<QStandardItemModel*>(m_materialTree->model());
QModelIndexList indexes = selected.indexes();
for (auto it = indexes.begin(); it != indexes.end(); it++) {
QStandardItem* item = model->itemFromIndex(*it);
@@ -711,7 +711,7 @@ void MaterialTreeWidget::onSelectMaterial(const QItemSelection& selected,
void MaterialTreeWidget::onDoubleClick(const QModelIndex& index)
{
auto model = dynamic_cast<QStandardItemModel*>(m_materialTree->model());
auto model = qobject_cast<QStandardItemModel*>(m_materialTree->model());
auto item = model->itemFromIndex(index);
if (item) {
@@ -739,7 +739,7 @@ void MaterialTreeWidget::saveMaterialTree()
param->Clear();
auto tree = m_materialTree;
auto model = dynamic_cast<QStandardItemModel*>(tree->model());
auto model = qobject_cast<QStandardItemModel*>(tree->model());
auto root = model->invisibleRootItem();
for (int i = 0; i < root->rowCount(); i++) {