Material: Replace dynamic_cast with qobject_cast
This commit is contained in:
committed by
Benjamin Nauck
parent
c704622605
commit
f2cd99c50a
@@ -208,7 +208,7 @@ void DlgInspectMaterial::updateMaterialTree(const Materials::Material& material)
|
||||
Base::Console().Log("Material '%s'\n", material.getName().toStdString().c_str());
|
||||
|
||||
auto tree = ui->treeMaterials;
|
||||
auto model = dynamic_cast<QStandardItemModel*>(tree->model());
|
||||
auto model = qobject_cast<QStandardItemModel*>(tree->model());
|
||||
model->clear();
|
||||
|
||||
addMaterial(tree, model, material);
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -651,7 +651,7 @@ void MaterialsEditor::saveMaterialTree(const Base::Reference<ParameterGrp>& para
|
||||
treeParam->Clear();
|
||||
|
||||
auto tree = ui->treeMaterials;
|
||||
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++) {
|
||||
@@ -847,7 +847,7 @@ void MaterialsEditor::fillMaterialTree()
|
||||
"User parameter:BaseApp/Preferences/Mod/Material/Editor/MaterialTree");
|
||||
|
||||
auto tree = ui->treeMaterials;
|
||||
auto model = dynamic_cast<QStandardItemModel*>(tree->model());
|
||||
auto model = qobject_cast<QStandardItemModel*>(tree->model());
|
||||
|
||||
if (_filterOptions.includeFavorites()) {
|
||||
auto lib = new QStandardItem(tr("Favorites"));
|
||||
@@ -898,7 +898,7 @@ void MaterialsEditor::createMaterialTree()
|
||||
void MaterialsEditor::refreshMaterialTree()
|
||||
{
|
||||
auto tree = ui->treeMaterials;
|
||||
auto model = dynamic_cast<QStandardItemModel*>(tree->model());
|
||||
auto model = qobject_cast<QStandardItemModel*>(tree->model());
|
||||
model->clear();
|
||||
|
||||
fillMaterialTree();
|
||||
@@ -1054,7 +1054,7 @@ QString MaterialsEditor::getColorHash(const QString& colorString, int colorRange
|
||||
void MaterialsEditor::updateMaterialAppearance()
|
||||
{
|
||||
QTreeView* tree = ui->treeAppearance;
|
||||
auto treeModel = dynamic_cast<QStandardItemModel*>(tree->model());
|
||||
auto treeModel = qobject_cast<QStandardItemModel*>(tree->model());
|
||||
treeModel->clear();
|
||||
|
||||
QStringList headers;
|
||||
@@ -1116,7 +1116,7 @@ void MaterialsEditor::updateMaterialAppearance()
|
||||
void MaterialsEditor::updateMaterialProperties()
|
||||
{
|
||||
QTreeView* tree = ui->treePhysicalProperties;
|
||||
auto treeModel = dynamic_cast<QStandardItemModel*>(tree->model());
|
||||
auto treeModel = qobject_cast<QStandardItemModel*>(tree->model());
|
||||
treeModel->clear();
|
||||
|
||||
QStringList headers;
|
||||
@@ -1233,7 +1233,7 @@ void MaterialsEditor::onSelectMaterial(const QItemSelection& selected,
|
||||
|
||||
// Get the UUID before changing the underlying data model
|
||||
QString uuid;
|
||||
auto model = dynamic_cast<QStandardItemModel*>(ui->treeMaterials->model());
|
||||
auto model = qobject_cast<QStandardItemModel*>(ui->treeMaterials->model());
|
||||
QModelIndexList indexes = selected.indexes();
|
||||
for (auto it = indexes.begin(); it != indexes.end(); it++) {
|
||||
QStandardItem* item = model->itemFromIndex(*it);
|
||||
|
||||
@@ -389,7 +389,7 @@ void ModelSelect::createModelProperties()
|
||||
void ModelSelect::updateModelProperties(std::shared_ptr<Materials::Model> model)
|
||||
{
|
||||
QTableView* table = ui->tableProperties;
|
||||
auto tableModel = dynamic_cast<QStandardItemModel*>(table->model());
|
||||
auto tableModel = qobject_cast<QStandardItemModel*>(table->model());
|
||||
tableModel->clear();
|
||||
|
||||
setHeaders(tableModel);
|
||||
@@ -454,7 +454,7 @@ void ModelSelect::clearMaterialModel()
|
||||
ui->tabWidget->setTabText(1, tr("Properties"));
|
||||
|
||||
QTableView* table = ui->tableProperties;
|
||||
auto tableModel = dynamic_cast<QStandardItemModel*>(table->model());
|
||||
auto tableModel = qobject_cast<QStandardItemModel*>(table->model());
|
||||
tableModel->clear();
|
||||
|
||||
setHeaders(tableModel);
|
||||
@@ -465,7 +465,7 @@ void ModelSelect::onSelectModel(const QItemSelection& selected, const QItemSelec
|
||||
{
|
||||
Q_UNUSED(deselected);
|
||||
|
||||
auto model = dynamic_cast<QStandardItemModel*>(ui->treeModels->model());
|
||||
auto model = qobject_cast<QStandardItemModel*>(ui->treeModels->model());
|
||||
QModelIndexList indexes = selected.indexes();
|
||||
for (auto it = indexes.begin(); it != indexes.end(); it++) {
|
||||
QStandardItem* item = model->itemFromIndex(*it);
|
||||
|
||||
Reference in New Issue
Block a user