From 45efe595480220cc73a90519f37dfd5768acaf32 Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Tue, 8 Mar 2016 11:31:25 +0100
Subject: [PATCH] On the way to refactor MaterialEditor (simplified
 MaterialItem and no UniversalPropertyEditor)

---
 GUI/coregui/Models/IconProvider.cpp           |  27 +-
 GUI/coregui/Models/IconProvider.h             |   4 +-
 GUI/coregui/Models/MaterialItem.cpp           |  51 +--
 GUI/coregui/Models/MaterialItem.h             |  12 +-
 GUI/coregui/Models/SessionModel.cpp           |  15 +-
 GUI/coregui/Models/SessionModel.h             |   7 +-
 .../Views/MaterialEditor/MaterialEditor.cpp   |  22 ++
 .../Views/MaterialEditor/MaterialEditor.h     |   6 +
 .../MaterialEditor/MaterialEditorDialog.cpp   | 149 +++----
 .../MaterialEditor/MaterialEditorDialog.h     |  30 +-
 .../MaterialEditor/MaterialEditorWidget.cpp   |   6 +-
 .../Views/MaterialEditor/MaterialProperty.cpp |   6 +-
 .../MaterialPropertyBrowser.cpp               | 365 ------------------
 .../MaterialEditor/MaterialPropertyBrowser.h  | 124 ------
 .../Views/MaterialEditor/MaterialUtils.cpp    |  37 +-
 GUI/coregui/mainwindow/mainwindow.cpp         |   1 +
 16 files changed, 175 insertions(+), 687 deletions(-)
 delete mode 100644 GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.cpp
 delete mode 100644 GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.h

diff --git a/GUI/coregui/Models/IconProvider.cpp b/GUI/coregui/Models/IconProvider.cpp
index c332f27fb31..c435759e489 100644
--- a/GUI/coregui/Models/IconProvider.cpp
+++ b/GUI/coregui/Models/IconProvider.cpp
@@ -15,15 +15,28 @@
 
 #include "IconProvider.h"
 #include "item_constants.h"
+#include "SessionItem.h"
+#include "MaterialItem.h"
 #include <QPixmap>
 
-QIcon IconProvider::icon(const QString &modelType)
+QIcon IconProvider::icon(const SessionItem *item)
 {
-    if(modelType == Constants::InstrumentType) {
-        QIcon icon;
-        icon.addPixmap(QPixmap(":/images/gisas_instrument_bw.png"),QIcon::Normal);
-        icon.addPixmap(QPixmap(":/images/gisas_instrument.png"),QIcon::Selected);
-        return icon;
+    Q_ASSERT(item);
+    QIcon result;
+
+    if(item->modelType() == Constants::InstrumentType) {
+        result.addPixmap(QPixmap(":/images/gisas_instrument_bw.png"), QIcon::Normal);
+        result.addPixmap(QPixmap(":/images/gisas_instrument.png"), QIcon::Selected);
     }
-    return QIcon();
+
+    else if(item->modelType() == Constants::MaterialType) {
+        if(const MaterialItem *materialItem = dynamic_cast<const MaterialItem *>(item)) {
+            QPixmap pixmap(10,10);
+            pixmap.fill(materialItem->getColor());
+            result.addPixmap(pixmap);
+        }
+
+    }
+
+    return result;
 }
diff --git a/GUI/coregui/Models/IconProvider.h b/GUI/coregui/Models/IconProvider.h
index eff0f17b33c..b7b81d16c3a 100644
--- a/GUI/coregui/Models/IconProvider.h
+++ b/GUI/coregui/Models/IconProvider.h
@@ -20,6 +20,8 @@
 #include <QIcon>
 #include <QString>
 
+class SessionItem;
+
 //! Class which returns icons for SessionItems to use in SessionModel
 class BA_CORE_API_ IconProvider
 {
@@ -27,7 +29,7 @@ public:
     IconProvider(){}
     virtual ~IconProvider(){}
 
-    virtual QIcon icon(const QString &modelType);
+    virtual QIcon icon(const SessionItem *item);
 
 };
 
diff --git a/GUI/coregui/Models/MaterialItem.cpp b/GUI/coregui/Models/MaterialItem.cpp
index a46af647471..308bfb64ffc 100644
--- a/GUI/coregui/Models/MaterialItem.cpp
+++ b/GUI/coregui/Models/MaterialItem.cpp
@@ -20,76 +20,47 @@
 #include "ScientificDoubleProperty.h"
 #include "ComboProperty.h"
 #include "GUIHelpers.h"
+#include "HomogeneousMaterial.h"
 #include <QUuid>
 #include <QDebug>
 
 
-const QString MaterialItem::P_MATERIAL_TYPE = "Material Type";
 const QString MaterialItem::P_COLOR = "Color";
 const QString MaterialItem::P_REFRACTIVE_INDEX = "Refractive index";
-const QString MaterialItem::P_MAGNETIC_FIELD = "Magnetic field";
 const QString MaterialItem::P_IDENTIFIER = "Identifier";
 
-
 MaterialItem::MaterialItem()
     : SessionItem(Constants::MaterialType)
 {
-//    registerProperty(OBSOLETE_P_NAME, Constants::MaterialType);
-//    setItemName(Constants::MaterialType);
-
-    ComboProperty types;
-    types << Constants::HomogeneousMaterialType << Constants::HomogeneousMagneticMaterialType;
-    registerProperty(P_MATERIAL_TYPE, types.getVariant());
-    getItem(P_MATERIAL_TYPE)->setVisible(false);
+    setItemName(Constants::MaterialType);
 
     ColorProperty color;
     registerProperty(P_COLOR, color.getVariant());
-
     registerGroupProperty(P_REFRACTIVE_INDEX, Constants::RefractiveIndexType);
-
     registerProperty(P_IDENTIFIER, QUuid::createUuid().toString());
     getItem(P_IDENTIFIER)->setVisible(false);
 }
 
-void MaterialItem::setMaterialType(int index)
-{
-    ComboProperty combo_property = getRegisteredProperty(P_MATERIAL_TYPE).value<ComboProperty>();
-    QString previous_type = combo_property.getValue();
-    QString new_type = combo_property.toString(index);
-
-    if(previous_type != new_type) {
-        if(new_type == Constants::HomogeneousMagneticMaterialType) {
-            registerGroupProperty(P_MAGNETIC_FIELD, Constants::MagneticFieldType);
-        } else {
-            removeRegisteredProperty(P_MAGNETIC_FIELD);
-        }
-
-        qDebug() << "MaterialItem::setMaterialType()" << index << combo_property.toString(index);
-        combo_property.setValue(new_type);
-        setRegisteredProperty(MaterialItem::P_MATERIAL_TYPE, combo_property.getVariant());
-    }
-}
-
 QString MaterialItem::getIdentifier() const
 {
     return getRegisteredProperty(P_IDENTIFIER).toString();
 }
 
-
 QColor MaterialItem::getColor() const
 {
     ColorProperty color_property = getRegisteredProperty(P_COLOR).value<ColorProperty>();
     return color_property.getColor();
 }
 
-bool MaterialItem::isHomogeneousMaterial() const
+std::unique_ptr<IMaterial> MaterialItem::createMaterial() const
 {
-    ComboProperty combo_property = getRegisteredProperty(MaterialItem::P_MATERIAL_TYPE).value<ComboProperty>();
-    return (combo_property.getValue() == Constants::HomogeneousMaterialType);
-}
+    const RefractiveIndexItem *refractiveIndexItem
+        = dynamic_cast<const RefractiveIndexItem *>(
+            getGroupItem(MaterialItem::P_REFRACTIVE_INDEX));
 
-bool MaterialItem::isHomogeneousMagneticMaterial() const
-{
-    ComboProperty combo_property = getRegisteredProperty(MaterialItem::P_MATERIAL_TYPE).value<ComboProperty>();
-    return (combo_property.getValue() == Constants::HomogeneousMagneticMaterialType);
+    double delta = refractiveIndexItem->getDelta();
+    double beta = refractiveIndexItem->getBeta();
+
+    return GUIHelpers::make_unique<HomogeneousMaterial>(
+                itemName().toStdString(), delta, beta);
 }
diff --git a/GUI/coregui/Models/MaterialItem.h b/GUI/coregui/Models/MaterialItem.h
index 6352da580f0..199f34456ed 100644
--- a/GUI/coregui/Models/MaterialItem.h
+++ b/GUI/coregui/Models/MaterialItem.h
@@ -19,27 +19,21 @@
 #include "SessionItem.h"
 #include <QColor>
 
+class IMaterial;
+
 class BA_CORE_API_ MaterialItem : public SessionItem
 {
     Q_OBJECT
 
 public:
-    static const QString P_MATERIAL_TYPE;
     static const QString P_COLOR;
     static const QString P_REFRACTIVE_INDEX;
-    static const QString P_MAGNETIC_FIELD;
     static const QString P_IDENTIFIER;
     explicit MaterialItem();
-    virtual ~MaterialItem() {}
-    void setMaterialType(int index);
 
     QString getIdentifier() const;
-
     QColor getColor() const;
-
-    bool isHomogeneousMaterial() const;
-
-    bool isHomogeneousMagneticMaterial() const;
+    std::unique_ptr<IMaterial> createMaterial() const;
 };
 
 #endif
diff --git a/GUI/coregui/Models/SessionModel.cpp b/GUI/coregui/Models/SessionModel.cpp
index fed75215157..f10d642deab 100644
--- a/GUI/coregui/Models/SessionModel.cpp
+++ b/GUI/coregui/Models/SessionModel.cpp
@@ -45,7 +45,6 @@ SessionModel::SessionModel(QString model_tag, QObject *parent)
     , m_root_item(0)
     , m_name("DefaultName")
     , m_model_tag(model_tag)
-    , m_iconProvider(0)
     , m_messageService(0)
 {
     createRootItem();
@@ -63,7 +62,6 @@ void SessionModel::createRootItem()
 SessionModel::~SessionModel()
 {
     delete m_root_item;
-    delete m_iconProvider;
 }
 
 Qt::ItemFlags SessionModel::flags(const QModelIndex &index) const
@@ -97,7 +95,7 @@ QVariant SessionModel::data(const QModelIndex &index, int role) const
             if (index.column() == ITEM_NAME)
                 return item->itemName();
         } else if (role == Qt::DecorationRole && m_iconProvider) {
-            return m_iconProvider->icon(item->modelType());
+            return m_iconProvider->icon(item);
         }
     }
     return QVariant();
@@ -545,7 +543,11 @@ SessionItem *SessionModel::insertNewItem(QString model_type, SessionItem *parent
 //    if (!m_root_item) {
 //        m_root_item = ItemFactory::createEmptyItem();
 //    }
-
+    Q_ASSERT(0); // g.p. What to do here?
+    Q_UNUSED(model_type);
+    Q_UNUSED(parent);
+    Q_UNUSED(row);
+    return 0;
 }
 
 void SessionModel::initFrom(SessionModel *model, SessionItem *parent)
@@ -596,3 +598,8 @@ void SessionModel::report_error(const QString &error_type, const QString &messag
 SessionItem* SessionModel::rootItem() const{
     return m_root_item;
 }
+
+void SessionModel::setIconProvider(IconProvider *icon_provider)
+{
+    m_iconProvider.reset(icon_provider);
+}
diff --git a/GUI/coregui/Models/SessionModel.h b/GUI/coregui/Models/SessionModel.h
index ad7ae78a460..8055749fbef 100644
--- a/GUI/coregui/Models/SessionModel.h
+++ b/GUI/coregui/Models/SessionModel.h
@@ -130,7 +130,7 @@ private:
     QString m_dragged_item_type;
     QString m_name;      //!< model name
     QString m_model_tag; //!< model tag (SampleModel, InstrumentModel)
-    IconProvider *m_iconProvider;
+    std::unique_ptr<IconProvider> m_iconProvider;
     WarningMessageService *m_messageService;
 };
 
@@ -169,9 +169,4 @@ inline void SessionModel::setDraggedItemType(const QString &type)
     m_dragged_item_type = type;
 }
 
-inline void SessionModel::setIconProvider(IconProvider *icon_provider)
-{
-    m_iconProvider = icon_provider;
-}
-
 #endif // SESSIONMODEL_H
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp
index 616a0b45bf9..ba3c9ae54f5 100644
--- a/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp
+++ b/GUI/coregui/Views/MaterialEditor/MaterialEditor.cpp
@@ -106,9 +106,31 @@ MaterialModel *MaterialEditor::getMaterialModel()
     return m_instance->this_getMaterialModel();
 }
 
+MaterialItem *MaterialEditor::getMaterial(const MaterialProperty &property)
+{
+    Q_ASSERT(m_instance);
+    return m_instance->this_getMaterial(property);
+}
+
+//MaterialItem *MaterialEditor::getMaterial(const QString &material_name)
+//{
+//    Q_ASSERT(m_instance);
+//    return m_instance->this_getMaterial(material_name);
+//}
+
 
 MaterialModel *MaterialEditor::this_getMaterialModel()
 {
     return m_materialModel;
 }
 
+MaterialItem *MaterialEditor::this_getMaterial(const MaterialProperty &property)
+{
+    return this_getMaterialModel()->getMaterial(property);
+}
+
+//MaterialItem *MaterialEditor::this_getMaterial(const QString &material_name)
+//{
+//    return this_getMaterialModel()->getMaterial(material_name);
+//}
+
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditor.h b/GUI/coregui/Views/MaterialEditor/MaterialEditor.h
index d661f61f943..4c4307f1071 100644
--- a/GUI/coregui/Views/MaterialEditor/MaterialEditor.h
+++ b/GUI/coregui/Views/MaterialEditor/MaterialEditor.h
@@ -22,6 +22,7 @@
 
 class MaterialModel;
 class SessionModel;
+class MaterialItem;
 
 //! The MaterialEditor is the main class to access materials.
 class BA_CORE_API_ MaterialEditor : public QObject
@@ -39,11 +40,16 @@ public:
 
     static MaterialModel *getMaterialModel();
 
+    static MaterialItem *getMaterial(const MaterialProperty &property);
+//    MaterialItem *getMaterial(const QString &material_name);
+
 private:
     MaterialProperty this_selectMaterialProperty();
     MaterialProperty this_getMaterialProperty(const QString &name);
     MaterialProperty this_getDefaultMaterialProperty();
     MaterialModel *this_getMaterialModel();
+    MaterialItem *this_getMaterial(const MaterialProperty &property);
+//    MaterialItem *this_getMaterial(const QString &material_name);
 
     static MaterialEditor *m_instance;
     MaterialModel *m_materialModel;
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp
index 5976a6eae53..e56425e7ee0 100644
--- a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp
+++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.cpp
@@ -14,47 +14,48 @@
 // ************************************************************************** //
 
 #include "MaterialEditorDialog.h"
-#include "MaterialPropertyBrowser.h"
 #include "MaterialModel.h"
+#include "MaterialEditorWidget.h"
 #include "MaterialUtils.h"
-#include <QStyle>
-#include <QStatusBar>
-#include <QToolBar>
+//#include <QStyle>
+//#include <QStatusBar>
+//#include <QToolBar>
 #include <QVBoxLayout>
 #include <QPushButton>
 #include <QAction>
 #include <QDebug>
-#include <QtTreePropertyBrowser>
+//#include <QtTreePropertyBrowser>
 
 
-int MaterialEditorDialog::m_IndexOfUnnamed = 0;
+//int MaterialEditorDialog::m_IndexOfUnnamed = 0;
 
 MaterialEditorDialog::MaterialEditorDialog(MaterialModel *materialModel, QWidget *parent)
     : QDialog(parent)
-    , m_materialModel(materialModel)
-    , m_propertyBrowser(new MaterialPropertyBrowser(materialModel, this))
-    , m_statusBar(0)
-    , m_toolBar(0)
+//    , m_materialModel(materialModel)
+    , m_materialEditor(new MaterialEditorWidget(materialModel, this))
+//    , m_propertyBrowser(new MaterialPropertyBrowser(materialModel, this))
+//    , m_statusBar(0)
+//    , m_toolBar(0)
 {
     setWindowTitle("Material Editor");
     setMinimumSize(128, 128);
     resize(512, 400);
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
-    m_toolBar = new QToolBar;
-    m_toolBar->setFixedHeight(28);
-    m_toolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-    const int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
-    m_toolBar->setIconSize(QSize(size, size));
-    m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+//    m_toolBar = new QToolBar;
+//    m_toolBar->setFixedHeight(28);
+//    m_toolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+//    const int size = style()->pixelMetric(QStyle::PM_SmallIconSize);
+//    m_toolBar->setIconSize(QSize(size, size));
+//    m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
 
-    m_statusBar = new QStatusBar;
+//    m_statusBar = new QStatusBar;
 
     QVBoxLayout *layout = new QVBoxLayout(this);
     layout->setMargin(0);
     layout->setSpacing(0);
-    layout->addWidget(m_toolBar);
-    layout->addWidget(m_propertyBrowser);
+    layout->addWidget(m_materialEditor);
+//    layout->addWidget(m_propertyBrowser);
 
     QPushButton *selectButton = new QPushButton(tr("Select"));
     connect(selectButton, SIGNAL(clicked()), this, SLOT(onSelectButton()));
@@ -70,86 +71,86 @@ MaterialEditorDialog::MaterialEditorDialog(MaterialModel *materialModel, QWidget
     buttonsLayout->addWidget(cancelButton);
 
     layout->addLayout(buttonsLayout);
-    layout->addWidget(m_statusBar);
+//    layout->addWidget(m_statusBar);
 
     setLayout(layout);
 
-    setupActions();
+//    setupActions();
 }
 
 
-void MaterialEditorDialog::setModel(MaterialModel *materialModel)
-{
-    Q_ASSERT(materialModel);
-    if(materialModel != m_materialModel) {
-        m_materialModel = materialModel;
-        m_propertyBrowser->setModel(materialModel);
-    }
+//void MaterialEditorDialog::setModel(MaterialModel *materialModel)
+//{
+//    Q_ASSERT(materialModel);
+//    if(materialModel != m_materialModel) {
+//        m_materialModel = materialModel;
+//        m_propertyBrowser->setModel(materialModel);
+//    }
 
-}
+//}
 
 
-void MaterialEditorDialog::showMessage(const QString &message)
-{
-    m_statusBar->showMessage(message, 4000);
-}
+//void MaterialEditorDialog::showMessage(const QString &message)
+//{
+//    m_statusBar->showMessage(message, 4000);
+//}
 
 
-void MaterialEditorDialog::onSelectButton()
-{
-    if(m_propertyBrowser->getSelectedMaterial()) {
-        accept();
-    } else {
-        showMessage("Please select material");
-    }
-}
+//void MaterialEditorDialog::onSelectButton()
+//{
+//    if(m_propertyBrowser->getSelectedMaterial()) {
+//        accept();
+//    } else {
+//        showMessage("Please select material");
+//    }
+//}
 
 
-void MaterialEditorDialog::onCancelButton()
-{
-    reject();
-}
+//void MaterialEditorDialog::onCancelButton()
+//{
+//    reject();
+//}
 
 
 
-void MaterialEditorDialog::setupActions()
-{
-    QAction *addMaterialAction = new QAction(QIcon(":/SampleDesigner/images/card--plus.png"), tr("Add material"), this);
-    connect(addMaterialAction, SIGNAL(triggered()), this, SLOT(addMaterial()));
-    m_toolBar->addAction(addMaterialAction);
+//void MaterialEditorDialog::setupActions()
+//{
+//    QAction *addMaterialAction = new QAction(QIcon(":/SampleDesigner/images/card--plus.png"), tr("Add material"), this);
+//    connect(addMaterialAction, SIGNAL(triggered()), this, SLOT(addMaterial()));
+//    m_toolBar->addAction(addMaterialAction);
 
-    QAction *removeMaterialAction = new QAction(QIcon(":/SampleDesigner/images/card--minus.png"), tr("Remove selected material"), this);
-    connect(removeMaterialAction, SIGNAL(triggered()), this, SLOT(removeMaterial()));
-    m_toolBar->addAction(removeMaterialAction);
-}
+//    QAction *removeMaterialAction = new QAction(QIcon(":/SampleDesigner/images/card--minus.png"), tr("Remove selected material"), this);
+//    connect(removeMaterialAction, SIGNAL(triggered()), this, SLOT(removeMaterial()));
+//    m_toolBar->addAction(removeMaterialAction);
+//}
 
 
-void MaterialEditorDialog::addMaterial()
-{
-    qDebug() << "MaterialEditorWidget::addMaterial() -> ";
-    QString name = QString("unnamed%1").arg(m_IndexOfUnnamed);
-    m_materialModel->addMaterial(name);
-    m_IndexOfUnnamed++;
-}
+//void MaterialEditorDialog::addMaterial()
+//{
+//    qDebug() << "MaterialEditorWidget::addMaterial() -> ";
+//    QString name = QString("unnamed%1").arg(m_IndexOfUnnamed);
+//    m_materialModel->addMaterial(name);
+//    m_IndexOfUnnamed++;
+//}
 
 
-void MaterialEditorDialog::removeMaterial()
-{
-    qDebug() << "MaterialEditorWidget::removeMaterial() -> ";
-    MaterialItem *material = m_propertyBrowser->getSelectedMaterial();
-    if(material) {
-        m_materialModel->removeMaterial(material);
-    } else {
-        showMessage("Select material to remove");
-    }
-}
+//void MaterialEditorDialog::removeMaterial()
+//{
+//    qDebug() << "MaterialEditorWidget::removeMaterial() -> ";
+//    MaterialItem *material = m_propertyBrowser->getSelectedMaterial();
+//    if(material) {
+//        m_materialModel->removeMaterial(material);
+//    } else {
+//        showMessage("Select material to remove");
+//    }
+//}
 
 
 MaterialProperty MaterialEditorDialog::getSelectedMaterialProperty()
 {
-    MaterialItem *material = m_propertyBrowser->getSelectedMaterial();
-    if(material)
-        return MaterialProperty(material->getIdentifier());
+//    MaterialItem *material = m_propertyBrowser->getSelectedMaterial();
+//    if(material)
+//        return MaterialProperty(material->getIdentifier());
 
     return MaterialProperty();
 }
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h
index 546bb5fb40a..9beb36f9139 100644
--- a/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h
+++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorDialog.h
@@ -21,11 +21,8 @@
 #include "MaterialProperty.h"
 #include "WinDllMacros.h"
 
-
 class MaterialModel;
-class MaterialPropertyBrowser;
-class QStatusBar;
-class QToolBar;
+class MaterialEditorWidget;
 
 //! Main widget of MaterialEditor
 class BA_CORE_API_ MaterialEditorDialog : public QDialog
@@ -33,29 +30,24 @@ class BA_CORE_API_ MaterialEditorDialog : public QDialog
     Q_OBJECT
 
 public:
+    MaterialEditorDialog(MaterialModel *materialModel, QWidget *parent = 0);
 
-    explicit MaterialEditorDialog(MaterialModel *materialModel, QWidget *parent = 0);
-    virtual ~MaterialEditorDialog(){}
-
-    void setModel(MaterialModel *materialModel);
+//    void setModel(MaterialModel *materialModel);
 
     MaterialProperty getSelectedMaterialProperty();
 
 public slots:
-    void addMaterial();
-    void removeMaterial();
-    void showMessage(const QString &message);
-    void onSelectButton();
-    void onCancelButton();
+//    void addMaterial();
+//    void removeMaterial();
+//    void showMessage(const QString &message);
+//    void onSelectButton();
+//    void onCancelButton();
 
 private:
-    void setupActions();
+//    void setupActions();
 
-    MaterialModel *m_materialModel;
-    MaterialPropertyBrowser *m_propertyBrowser;
-    QStatusBar *m_statusBar;
-    QToolBar *m_toolBar;
-    static int m_IndexOfUnnamed;
+//    MaterialModel *m_materialModel;
+    MaterialEditorWidget *m_materialEditor;
 };
 
 
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialEditorWidget.cpp b/GUI/coregui/Views/MaterialEditor/MaterialEditorWidget.cpp
index e925cf84a9b..8e23d797519 100644
--- a/GUI/coregui/Views/MaterialEditor/MaterialEditorWidget.cpp
+++ b/GUI/coregui/Views/MaterialEditor/MaterialEditorWidget.cpp
@@ -66,11 +66,11 @@ void MaterialEditorWidget::onSelectionChanged(const QItemSelection &selected,
 void MaterialEditorWidget::init_views()
 {
     m_listView->setModel(m_materialModel);
-    m_listView->setViewMode(QListView::IconMode);
-    m_listView->setIconSize(QSize(96, 84));
+//    m_listView->setViewMode(QListView::IconMode);
+//    m_listView->setIconSize(QSize(96, 84));
     m_listView->setMovement(QListView::Static);
     m_listView->setMaximumWidth(200);
-    m_listView->setSpacing(12);
+    m_listView->setSpacing(5);
 
 
 
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp b/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp
index 5e1ec2b6f2c..01d2e5fdd28 100644
--- a/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp
+++ b/GUI/coregui/Views/MaterialEditor/MaterialProperty.cpp
@@ -21,9 +21,9 @@
 QString MaterialProperty::getName() const
 {
     MaterialProperty property(getIdentifier());
-    MaterialItem *materialItem = MaterialEditor::getMaterialModel()->getMaterial(property);
+    MaterialItem *materialItem = MaterialEditor::getMaterial(property);
     if(materialItem) {
-        return materialItem->itemName();
+        return materialItem->itemName();
     } else {
         return QString("Undefined");
     }
@@ -33,7 +33,7 @@ QString MaterialProperty::getName() const
 QColor MaterialProperty::getColor() const
 {
     MaterialProperty property(getIdentifier());
-    MaterialItem *materialItem = MaterialEditor::getMaterialModel()->getMaterial(property);
+    MaterialItem *materialItem = MaterialEditor::getMaterial(property);
     if(materialItem) {
         return materialItem->getColor();
     } else {
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.cpp b/GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.cpp
deleted file mode 100644
index 02453671838..00000000000
--- a/GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.cpp
+++ /dev/null
@@ -1,365 +0,0 @@
-// ************************************************************************** //
-//
-//  BornAgain: simulate and fit scattering at grazing incidence
-//
-//! @file      coregui/Views/MaterialEditor/MaterialPropertyBrowser.cpp
-//! @brief     Implements class MaterialPropertyBrowser
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2015
-//! @authors   Scientific Computing Group at MLZ Garching
-//! @authors   C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
-//
-// ************************************************************************** //
-
-#include "MaterialPropertyBrowser.h"
-#include "MaterialModel.h"
-#include "MaterialItem.h"
-#include "ComboProperty.h"
-#include "PropertyVariantManager.h"
-#include "PropertyVariantFactory.h"
-#include "qttreepropertybrowser.h"
-#include "tooltipdatabase.h"
-#include "ScientificDoubleProperty.h"
-#include "GUIHelpers.h"
-#include "PropertyAttribute.h"
-#include <QtVariantPropertyManager>
-#include <QtProperty>
-#include <QtVariantProperty>
-#include <QtTreePropertyBrowser>
-#include <QVBoxLayout>
-#include <QDebug>
-#include <QEvent>
-#include <QApplication>
-#include <QTreeWidget>
-#include <qtpropertybrowser.h>
-
-
-MaterialPropertyBrowser::MaterialPropertyBrowser(MaterialModel *materialModel, QWidget *parent)
-    : QWidget(parent)
-    , m_materialModel(0)
-    , m_browser(0)
-    , m_variantManager(0)
-    , m_selection_changed(false)
-
-{
-    m_browser = new QtTreePropertyBrowser(this);
-    m_readOnlyManager = new PropertyVariantManager(this);
-    m_variantManager = new PropertyVariantManager(this);
-//    m_variantFactory = new PropertyVariantFactory(this);
-//    m_browser->setFactoryForManager(m_variantManager, m_variantFactory);
-
-    QtVariantEditorFactory *factory = new PropertyVariantFactory();
-    m_browser->setFactoryForManager(m_variantManager, factory);
-
-
-    connect(m_variantManager, SIGNAL(valueChanged(QtProperty *, const QVariant &)),
-                this, SLOT(slotValueChanged(QtProperty *, const QVariant &)));
-
-    QVBoxLayout *layout = new QVBoxLayout(this);
-    layout->setMargin(0);
-    layout->addWidget(m_browser);
-    setLayout(layout);
-
-    setModel(materialModel);
-
-    // accessing selection model of private QTreeView of m_browser
-    QItemSelectionModel *selectionModel(0);
-    const QObjectList list = m_browser->children();
-    foreach(QObject *obj, list) {
-        QTreeView *view = dynamic_cast<QTreeView *>(obj);
-        if(view) selectionModel = view->selectionModel();
-    }
-    if(selectionModel) {
-        connect(selectionModel,
-            SIGNAL( selectionChanged(const QItemSelection&, const QItemSelection&) ),
-            this,
-            SLOT( onSelectionChanged(const QItemSelection&, const QItemSelection&) )
-            );
-    }
-}
-
-
-void MaterialPropertyBrowser::setModel(MaterialModel *materialModel)
-{
-    Q_ASSERT(materialModel);
-    if(materialModel != m_materialModel) {
-        m_materialModel = materialModel;
-        connect(m_materialModel, SIGNAL(rowsInserted(QModelIndex, int,int)), this, SLOT(onRowsInserted(QModelIndex, int,int)));
-        connect(m_materialModel, SIGNAL(rowsRemoved(QModelIndex, int,int)), this, SLOT(onRowsRemoved(QModelIndex, int,int)));
-        updateBrowser();
-    }
-}
-
-
-void MaterialPropertyBrowser::onRowsInserted(const QModelIndex & /*parent*/, int /*first*/, int /*last*/)
-{
-    clearBrowser();
-    updateBrowser();
-}
-
-
-void MaterialPropertyBrowser::onRowsRemoved(const QModelIndex & /*parent*/, int /*first*/, int /*last*/)
-{
-    clearBrowser();
-    updateBrowser();
-}
-
-
-void MaterialPropertyBrowser::slotValueChanged(QtProperty *property,
-                                            const QVariant &value)
-{
-    //qDebug() << "MaterialEditorWidget::slotValueChanged" << property << value;
-
-    if (!m_property_to_subitem.contains(property))
-        return;
-
-    qDebug() << "MaterialEditorWidget::slotValueChanged() -> 1.1";
-    if(m_top_property_to_material.contains(property)) {
-        qDebug() << "MaterialEditorWidget::slotValueChanged() -> 1.2";
-        MaterialItem *material = dynamic_cast<MaterialItem *>(m_top_property_to_material[property]);
-        disconnect(material, SIGNAL(propertyChanged(QString)),
-               this, SLOT(onPropertyChanged(QString)));
-        material->setMaterialType(value.toInt());
-        removeSubProperties(property);
-        addSubProperties(property, material);
-        connect(material, SIGNAL(propertyChanged(QString)),
-               this, SLOT(onPropertyChanged(QString)));
-
-        return;
-    }
-
-    qDebug() << "MaterialEditorWidget::slotValueChanged() -> 1.3";
-    //MaterialItem *material = dynamic_cast<MaterialItem *>(m_property_to_subitem[property].m_owner);
-    SessionItem *item = m_property_to_subitem[property].m_owner;
-    Q_ASSERT(item);
-    qDebug() << "MaterialEditorWidget::slotValueChanged() -> 1.4";
-    item->setRegisteredProperty(property->propertyName(), value);
-    qDebug() << "MaterialEditorWidget::slotValueChanged() -> 1.5";
-//    updateMaterialProperties(item);
-
-}
-
-void MaterialPropertyBrowser::onPropertyChanged(const QString &property_name)
-{
-    SessionItem *parentItem = qobject_cast<SessionItem *>(sender());
-
-
-    if(m_top_material_to_property.contains(parentItem)) {
-        m_top_material_to_property[parentItem]->setPropertyName(parentItem->itemName());
-    }
-
-
-    qDebug() << "MaterialPropertyBrowser::onPropertyChanged()" << property_name << parentItem->modelType();
-
-    QtVariantProperty *variant_property = m_material_to_property[parentItem][property_name];
-    if(variant_property) {
-        QVariant property_value = parentItem->getRegisteredProperty(property_name);
-
-        disconnect(parentItem, SIGNAL(propertyChanged(QString)),
-               this, SLOT(onPropertyChanged(QString)));
-
-        variant_property->setValue(property_value);
-
-        connect(parentItem, SIGNAL(propertyChanged(QString)),
-               this, SLOT(onPropertyChanged(QString)));
-    }
-
-
-}
-
-
-void MaterialPropertyBrowser::updateBrowser()
-{
-    Q_ASSERT(m_materialModel);
-
-    QModelIndex parentIndex;
-    for( int i_row = 0; i_row < m_materialModel->rowCount( parentIndex); ++i_row) {
-         QModelIndex itemIndex = m_materialModel->index( i_row, 0, parentIndex );
-
-         if (MaterialItem *material = dynamic_cast<MaterialItem *>(m_materialModel->itemForIndex(itemIndex))){
-             addMaterialProperties(material);
-             connect(material, SIGNAL(propertyChanged(QString)),
-                    this, SLOT(onPropertyChanged(QString)));
-
-         }
-    }
-    updateExpandState(RESTORE_EXPAND_STATE);
-}
-
-
-void MaterialPropertyBrowser::clearBrowser()
-{
-    updateExpandState(SAVE_EXPAND_STATE);
-    QMap<QtProperty *, SubItem>::iterator it = m_property_to_subitem.begin();
-    while(it!=m_property_to_subitem.end()) {
-        delete it.key();
-        it++;
-    }
-    m_property_to_subitem.clear();
-    m_top_property_to_material.clear();
-    m_top_material_to_property.clear();
-    m_material_to_property.clear();
-}
-
-
-//void MaterialPropertyBrowser::updateMaterialProperties(SessionItem *material)
-//{
-//    if(m_top_material_to_property.contains(material)) {
-//        m_top_material_to_property[material]->setPropertyName(material->itemName());
-//    }
-
-////    QMap<SessionItem *, QtVariantProperty *>::iterator it = m_top_material_to_property.begin();
-////    while(it!=m_top_material_to_property.end()) {
-////        updateSubProperties(it.key());
-////        ++it;
-////    }
-//}
-
-
-void MaterialPropertyBrowser::addMaterialProperties(SessionItem *material)
-{
-    QtVariantProperty *item_property = m_variantManager->addProperty(
-                QtVariantPropertyManager::enumTypeId(), material->itemName());
-
-    ComboProperty combo_property = material->getRegisteredProperty(MaterialItem::P_MATERIAL_TYPE).value<ComboProperty>();
-
-    item_property->setAttribute(QLatin1String("enumNames"), combo_property.getValues());
-    item_property->setValue(combo_property.getIndex());
-
-    addSubProperties(item_property, material);
-    m_browser->addProperty(item_property);
-
-    m_top_property_to_material[item_property] = material;
-    m_top_material_to_property[material] = item_property;
-    m_property_to_subitem[item_property] = SubItem(material, "");
-}
-
-
-void MaterialPropertyBrowser::removeSubProperties(QtProperty *property)
-{
-    qDebug() << "MaterialEditorWidget::updateMaterialProperties" << property->propertyName();
-    QList<QtProperty *> properties = property->subProperties();
-    foreach(QtProperty *child, properties) {
-        m_browser->removeProperty(child);
-        delete child;
-
-        QMap<QtProperty *, SubItem >::iterator it = m_property_to_subitem.find(child);
-        m_property_to_subitem.erase(it);
-    }
-}
-
-
-void MaterialPropertyBrowser::addSubProperties(QtProperty *material_property, SessionItem *item)
-{
-
-    QList<QByteArray> property_names = item->dynamicPropertyNames();
-    for (int i = 0; i < property_names.length(); ++i) {
-        QString prop_name = QString(property_names[i]);
-        const PropertyAttribute &prop_attribute = PropertyAttribute::fromItem(item);
-
-        if(prop_attribute.isHidden()) continue;
-
-        QVariant prop_value = item->property(prop_name.toUtf8().data());
-        int type = GUIHelpers::getVariantType(prop_value);
-
-        QtVariantProperty *subProperty = 0;
-        if (m_variantManager->isPropertyTypeSupported(type)) {
-
-            if(prop_attribute.getLabel().isEmpty()) {
-                subProperty = m_variantManager->addProperty(type, prop_name);
-            } else {
-                subProperty = m_variantManager->addProperty(type, prop_attribute.getLabel());
-            }
-
-            subProperty->setValue(prop_value);
-
-            QString toolTip = ToolTipDataBase::getSampleViewToolTip(item->modelType(), prop_name);
-            if(!toolTip.isEmpty()) subProperty->setToolTip(toolTip);
-
-            if(prop_attribute.isDisabled()) {
-                subProperty->setEnabled(false);
-            }
-
-            if (item->isGroupProperty(prop_name)) {
-                SessionItem *subitem = item->getGroupItem(prop_name);
-                if (subitem) {
-                    addSubProperties(subProperty, subitem);
-                }
-            }
-
-        } else {
-            subProperty = m_readOnlyManager->addProperty(QVariant::String,
-                                                         prop_name);
-            subProperty->setValue(QLatin1String("< Unknown Type >"));
-            subProperty->setEnabled(false);
-        }
-        material_property->addSubProperty(subProperty);
-        SubItem subitem(item,prop_name);
-        m_property_to_subitem[subProperty] = subitem;
-        m_material_to_property[item][prop_name] = subProperty;
-    }
-}
-
-
-
-
-//void MaterialPropertyBrowser::updateSubProperties(SessionItem *material)
-//{
-////    if(m_material_to_property.contains(material)) {
-
-////        QList<QByteArray> property_names = material->dynamicPropertyNames();
-////        for (int i = 0; i < property_names.length(); ++i) {
-////            QString prop_name = QString(property_names[i]);
-////            QVariant prop_value = material->property(prop_name.toUtf8().data());
-
-////            if(m_material_to_property[material].contains(prop_name)) {
-////                QtVariantProperty *vproperty = m_material_to_property[material][prop_name];
-////                if (material->getSubItems().contains(prop_name)) {
-////                    vproperty->setValue(prop_value);
-////                }
-////            }
-////        }
-////    }
-//}
-
-
-void MaterialPropertyBrowser::updateExpandState(EExpandAction action)
-{
-    QMap<QtProperty *, SubItem>::iterator it_prop = m_property_to_subitem.begin();
-    while(it_prop!=m_property_to_subitem.end()) {
-        QList<QtBrowserItem *> list = m_browser->items(it_prop.key());
-
-        QListIterator<QtBrowserItem *> it_browser(list);
-        while (it_browser.hasNext()) {
-            QtBrowserItem *item = it_browser.next();
-            QtProperty *prop = item->property();
-            if(action == SAVE_EXPAND_STATE) {
-                m_subItemToExpanded[m_property_to_subitem[prop]] = m_browser->isExpanded(item);
-            } else if (action == RESTORE_EXPAND_STATE) {
-                m_browser->setExpanded(item, m_subItemToExpanded[m_property_to_subitem[prop]]);
-            }
-        }
-        ++it_prop;
-    }
-}
-
-
-MaterialItem *MaterialPropertyBrowser::getSelectedMaterial()
-{
-    if(m_browser->currentItem() && m_selection_changed) {
-        QtProperty *selected_property = m_browser->currentItem()->property();
-        if(selected_property) {
-            if(m_top_property_to_material.contains(selected_property))
-                return dynamic_cast<MaterialItem *>(m_top_property_to_material[selected_property]);
-       }
-    }
-    return 0;
-}
-
-
-void MaterialPropertyBrowser::onSelectionChanged(const QItemSelection&, const QItemSelection&)
-{
-    m_selection_changed = true;
-}
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.h b/GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.h
deleted file mode 100644
index 0b8a7774c31..00000000000
--- a/GUI/coregui/Views/MaterialEditor/MaterialPropertyBrowser.h
+++ /dev/null
@@ -1,124 +0,0 @@
-// ************************************************************************** //
-//
-//  BornAgain: simulate and fit scattering at grazing incidence
-//
-//! @file      coregui/Views/MaterialEditor/MaterialPropertyBrowser.h
-//! @brief     Defines class MaterialPropertyBrowser
-//!
-//! @homepage  http://www.bornagainproject.org
-//! @license   GNU General Public License v3 or higher (see COPYING)
-//! @copyright Forschungszentrum Jülich GmbH 2015
-//! @authors   Scientific Computing Group at MLZ Garching
-//! @authors   C. Durniak, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke
-//
-// ************************************************************************** //
-
-#ifndef MATERIALPROPERTYBROWER_H
-#define MATERIALPROPERTYBROWER_H
-
-#include <QWidget>
-#include <QMap>
-#include <QString>
-
-#include "WinDllMacros.h"
-
-class MaterialModel;
-class MaterialItem;
-class QtTreePropertyBrowser;
-class QtAbstractPropertyBrowser;
-class QtVariantPropertyManager;
-class QtVariantEditorFactory;
-class QtProperty;
-class MaterialVariantManager;
-class QtVariantProperty;
-class QModelIndex;
-class QtBrowserItem;
-class QItemSelection;
-class SessionItem;
-
-
-//! Class which holds QtProperty tree browser to adjust material properties.
-//! Belongs to MaterialEditorWidget
-class BA_CORE_API_ MaterialPropertyBrowser : public QWidget
-{
-    Q_OBJECT
-
-public:
-    explicit MaterialPropertyBrowser(MaterialModel *materialModel, QWidget *parent = 0);
-    virtual ~MaterialPropertyBrowser(){}
-
-    void setModel(MaterialModel *materialModel);
-
-    struct SubItem {
-        SubItem(SessionItem *owner=0, QString name = QString())
-            : m_owner(owner), m_name(name) {}
-        SessionItem *m_owner;
-        QString m_name;
-        friend bool operator <(const SubItem& left, const SubItem& right)
-        {
-            if(left.m_owner == right.m_owner)
-                return left.m_name < right.m_name;
-            return left.m_owner < right.m_owner;
-        }
-    };
-
-
-//    struct ItemIndexPair {
-//        ItemIndexPair(SessionItem *item=0, int index=0)
-//            : m_item(item), m_index(index) {}
-//        SessionItem *m_item;
-//        int m_index;
-//    };
-
-
-    MaterialItem *getSelectedMaterial();
-
-public slots:
-    void onSelectionChanged(const QItemSelection&, const QItemSelection&);
-
-private slots:
-    void onRowsInserted(const QModelIndex &parent, int first, int last);
-    void onRowsRemoved(const QModelIndex &parent, int first, int last);
-    void slotValueChanged(QtProperty *property, const QVariant &value);
-    void onPropertyChanged(const QString &property_name);
-
-private:
-    void updateBrowser();
-    void clearBrowser();
-    void addMaterialProperties(SessionItem *material);
-//    void updateMaterialProperties(SessionItem *material);
-    void addSubProperties(QtProperty *property, SessionItem *item);
-    void removeSubProperties(QtProperty *property);
-//    void updateSubProperties(SessionItem *material);
-
-    enum EExpandAction { SAVE_EXPAND_STATE, RESTORE_EXPAND_STATE };
-    void updateExpandState(EExpandAction action);
-
-    MaterialModel *m_materialModel;
-    QtTreePropertyBrowser *m_browser;
-    QtVariantPropertyManager *m_variantManager;
-    QtVariantPropertyManager *m_readOnlyManager;
-    //QtVariantEditorFactory *m_variantFactory;
-
-    QMap<QtProperty *, SessionItem *> m_top_property_to_material;
-    QMap<SessionItem *, QtVariantProperty *> m_top_material_to_property;
-    QMap<QtProperty *, SubItem> m_property_to_subitem;
-    QMap<SessionItem *, QMap<QString, QtVariantProperty *> > m_material_to_property;
-
-
-//    QMap<QtProperty *, ItemIndexPair>     m_property_to_item_index_pair;
-//    QMap<const SessionItem *, QMap<int, QtVariantProperty *> >
-//        m_item_to_index_to_property;
-
-//    QMap<const SessionItem *, QMap<QString, QtVariantProperty *> >
-//        m_item_to_propertyname_to_qtvariantproperty;
-
-
-    QMap<SubItem, bool> m_subItemToExpanded;
-
-    bool m_selection_changed;
-};
-
-
-
-#endif
diff --git a/GUI/coregui/Views/MaterialEditor/MaterialUtils.cpp b/GUI/coregui/Views/MaterialEditor/MaterialUtils.cpp
index b3918c08ae8..b722216b6d5 100644
--- a/GUI/coregui/Views/MaterialEditor/MaterialUtils.cpp
+++ b/GUI/coregui/Views/MaterialEditor/MaterialUtils.cpp
@@ -60,38 +60,11 @@ ColorProperty MaterialUtils::suggestMaterialColorProperty(const QString &name)
     return ColorProperty(MaterialUtils::suggestMaterialColor(name));
 }
 
-
-std::unique_ptr<IMaterial> MaterialUtils::createDomainMaterial(const MaterialProperty &material_property)
+std::unique_ptr<IMaterial>
+MaterialUtils::createDomainMaterial(const MaterialProperty &material_property)
 {
-    MaterialModel *model = MaterialEditor::getMaterialModel();
-    Q_ASSERT(model);
-
-    const MaterialItem *materialItem = model->getMaterial(material_property);
+    MaterialItem *materialItem
+        = MaterialEditor::getMaterial(material_property);
     Q_ASSERT(materialItem);
-
-    const RefractiveIndexItem *refractiveIndexItem = dynamic_cast<const RefractiveIndexItem *>(materialItem->getGroupItem(MaterialItem::P_REFRACTIVE_INDEX));
-    double delta = refractiveIndexItem->getDelta();
-    double beta = refractiveIndexItem->getBeta();
-
-    if(materialItem->isHomogeneousMaterial()) {
-        return GUIHelpers::make_unique<HomogeneousMaterial>(
-                    materialItem->itemName().toStdString(), delta, beta);
-    }
-    else if(materialItem->isHomogeneousMagneticMaterial()) {
-        const MagneticFieldItem *magneticField = dynamic_cast<const MagneticFieldItem *>(materialItem->getGroupItem(MaterialItem::P_MAGNETIC_FIELD));
-        Q_ASSERT(magneticField);
-        double Bx = magneticField->getRegisteredProperty(MagneticFieldItem::P_BX).toDouble();
-        double By = magneticField->getRegisteredProperty(MagneticFieldItem::P_BY).toDouble();
-        double Bz = magneticField->getRegisteredProperty(MagneticFieldItem::P_BZ).toDouble();
-        return GUIHelpers::make_unique<HomogeneousMagneticMaterial>(
-                    materialItem->itemName().toStdString(),
-                    delta, beta, kvector_t(Bx, By, Bz));
-    }
-    else {
-        throw GUIHelpers::Error("MaterialUtils::createDomainMaterial() -> Error. Unknown material type.");
-    }
-
-    return nullptr;
+    return materialItem->createMaterial();
 }
-
-
diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp
index dd84afe67f5..7d76112fac8 100644
--- a/GUI/coregui/mainwindow/mainwindow.cpp
+++ b/GUI/coregui/mainwindow/mainwindow.cpp
@@ -267,6 +267,7 @@ void MainWindow::createMaterialModel()
 {
     delete m_materialModel;
     m_materialModel = new MaterialModel(this);
+    m_materialModel->setIconProvider(new IconProvider());
 //    m_materialModel->addMaterial("Default", 1e-3, 1e-5);
 //    m_materialModel->addMaterial("Air", 0.0, 0.0);
 //    m_materialModel->addMaterial("Particle", 6e-4, 2e-8);
-- 
GitLab