diff options
author | Tomi Korpipaa <tomi.korpipaa@qt.io> | 2019-01-24 11:22:40 +0200 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@qt.io> | 2019-01-25 09:17:56 +0000 |
commit | 0f19ad173474bc11fb745d5af50dede7535d80f6 (patch) | |
tree | da6dd2a03e67b709cdb587c97ca1ff10330b0f8f | |
parent | 63a8bd8b24c7b0228612e450ee877e08d7067f10 (diff) |
Don't show material container items in browser
Remove "Scene.__Container" and "materials//Default" from
object browser views.
Task-number: QT3DS-2777
Change-Id: Id9102d3bf88b3ca96c5a5737eee526195ba0b83f
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
3 files changed, 34 insertions, 2 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp index 0b6db847..41be5767 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectBrowserView.cpp @@ -30,6 +30,10 @@ #include "ObjectListModel.h" #include "StudioPreferences.h" #include "StudioUtils.h" +#include "StudioApp.h" +#include "Core.h" +#include "Qt3DSDMStudioSystem.h" +#include "ClientDataModelBridge.h" #include <QtCore/qtimer.h> #include <QtQml/qqmlcontext.h> @@ -50,10 +54,29 @@ QAbstractItemModel *ObjectBrowserView::model() const void ObjectBrowserView::setModel(ObjectListModel *model) { - if (!m_model) { + if (!m_model) m_model = new FlatObjectListModel(model, this); - } m_model->setSourceModel(model); + + const auto doc = g_StudioApp.GetCore()->GetDoc(); + const auto bridge = doc->GetStudioSystem()->GetClientDataModelBridge(); + + // Remove "Scene.__Container" and "materials//Default" entries + QModelIndexList list = m_model->match(m_model->index(0, 0), + ObjectListModel::AbsolutePathRole, + QStringLiteral("Scene.") + + bridge->getMaterialContainerName(), 1, + Qt::MatchFlags(Qt::MatchWrap | Qt::MatchExactly + | Qt::MatchRecursive)); + list.append(m_model->match(m_model->index(0, 0), + ObjectListModel::NameRole, + QStringLiteral("materials/") + bridge->getDefaultMaterialName(), 1, + Qt::MatchFlags(Qt::MatchWrap | Qt::MatchExactly + | Qt::MatchRecursive))); + + for (int i = list.size(); i > 0; i--) + m_model->removeRow(list.at(i - 1).row(), m_model->index(0, 0)); + m_ownerInstance = 0; m_selection = -1; diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp index 3bff2d7a..ad66274a 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.cpp @@ -407,6 +407,14 @@ int FlatObjectListModel::rowCount(const QModelIndex &parent) const return m_sourceInfo.count(); } +bool FlatObjectListModel::removeRows(int row, int count, const QModelIndex &parent) +{ + beginRemoveRows(parent, row, row + count - 1); + m_sourceInfo.remove(row, count); + endRemoveRows(); + return true; +} + void FlatObjectListModel::setSourceModel(ObjectListModel *sourceModel) { beginResetModel(); diff --git a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h index 89b5a93c..4013f15c 100644 --- a/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h +++ b/src/Authoring/Studio/Palettes/Inspector/ObjectListModel.h @@ -118,6 +118,7 @@ public: int role = Qt::DisplayRole) const; bool setData(const QModelIndex &index, const QVariant &data, int role = Qt::EditRole) override; int rowCount(const QModelIndex &parent = QModelIndex()) const override; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; void setSourceModel(ObjectListModel *sourceModel); ObjectListModel *sourceModel() const { return m_sourceModel; } |