* chore: simplify logic for handling expanding entries in Outliner Signed-off-by: Michael Pollind <mpollind@gmail.com> * bugfix: fix bottom border for collapsed prefabs. issue: https://github.com/o3de/o3de/issues/5219 Signed-off-by: Michael Pollind <mpollind@gmail.com> * chore: revert changes for expanding entities Signed-off-by: Michael Pollind <mpollind@gmail.com>
This commit is contained in:
+1
-12
@@ -80,7 +80,6 @@ namespace AzToolsFramework
|
||||
EntityOutlinerListModel::EntityOutlinerListModel(QObject* parent)
|
||||
: QAbstractItemModel(parent)
|
||||
, m_entitySelectQueue()
|
||||
, m_entityExpandQueue()
|
||||
, m_entityChangeQueue()
|
||||
, m_entityChangeQueued(false)
|
||||
, m_entityLayoutQueued(false)
|
||||
@@ -1275,7 +1274,6 @@ namespace AzToolsFramework
|
||||
void EntityOutlinerListModel::QueueEntityToExpand(AZ::EntityId entityId, bool expand)
|
||||
{
|
||||
m_entityExpansionState[entityId] = expand;
|
||||
m_entityExpandQueue.insert(entityId);
|
||||
QueueEntityUpdate(entityId);
|
||||
}
|
||||
|
||||
@@ -1300,16 +1298,7 @@ namespace AzToolsFramework
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
AZ_PROFILE_SCOPE(Editor, "EntityOutlinerListModel::ProcessEntityUpdates:ExpandQueue");
|
||||
for (auto entityId : m_entityExpandQueue)
|
||||
{
|
||||
emit ExpandEntity(entityId, IsExpanded(entityId));
|
||||
};
|
||||
m_entityExpandQueue.clear();
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
AZ_PROFILE_SCOPE(Editor, "EntityOutlinerListModel::ProcessEntityUpdates:SelectQueue");
|
||||
for (auto entityId : m_entitySelectQueue)
|
||||
|
||||
-2
@@ -156,7 +156,6 @@ namespace AzToolsFramework
|
||||
void ProcessEntityUpdates();
|
||||
|
||||
Q_SIGNALS:
|
||||
void ExpandEntity(const AZ::EntityId& entityId, bool expand);
|
||||
void SelectEntity(const AZ::EntityId& entityId, bool select);
|
||||
void EnableSelectionUpdates(bool enable);
|
||||
void ResetFilter();
|
||||
@@ -190,7 +189,6 @@ namespace AzToolsFramework
|
||||
void QueueEntityToExpand(AZ::EntityId entityId, bool expand);
|
||||
void ProcessEntityInfoResetEnd();
|
||||
AZStd::unordered_set<AZ::EntityId> m_entitySelectQueue;
|
||||
AZStd::unordered_set<AZ::EntityId> m_entityExpandQueue;
|
||||
AZStd::unordered_set<AZ::EntityId> m_entityChangeQueue;
|
||||
bool m_entityChangeQueued;
|
||||
bool m_entityLayoutQueued;
|
||||
|
||||
+55
@@ -81,6 +81,61 @@ namespace AzToolsFramework
|
||||
update();
|
||||
}
|
||||
|
||||
void EntityOutlinerTreeView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
|
||||
{
|
||||
AzQtComponents::StyledTreeView::dataChanged(topLeft, bottomRight, roles);
|
||||
|
||||
if (topLeft.isValid() && topLeft.parent() == bottomRight.parent() && topLeft.row() <= bottomRight.row() &&
|
||||
topLeft.column() <= bottomRight.column())
|
||||
{
|
||||
for (int i = topLeft.row(); i <= bottomRight.row(); i++)
|
||||
{
|
||||
auto modelRow = topLeft.sibling(i, EntityOutlinerListModel::ColumnName);
|
||||
if (modelRow.isValid())
|
||||
{
|
||||
checkExpandedState(modelRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EntityOutlinerTreeView::rowsInserted(const QModelIndex& parent, int start, int end)
|
||||
{
|
||||
if (parent.isValid())
|
||||
{
|
||||
for (int i = start; i <= end; i++)
|
||||
{
|
||||
auto modelRow = model()->index(i, EntityOutlinerListModel::ColumnName, parent);
|
||||
if (modelRow.isValid())
|
||||
{
|
||||
checkExpandedState(modelRow);
|
||||
recursiveCheckExpandedStates(modelRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
AzQtComponents::StyledTreeView::rowsInserted(parent, start, end);
|
||||
}
|
||||
|
||||
void EntityOutlinerTreeView::recursiveCheckExpandedStates(const QModelIndex& current)
|
||||
{
|
||||
const int rowCount = model()->rowCount(current);
|
||||
for (int i = 0; i < rowCount; i++)
|
||||
{
|
||||
auto modelRow = model()->index(i, EntityOutlinerListModel::ColumnName, current);
|
||||
if (modelRow.isValid())
|
||||
{
|
||||
checkExpandedState(modelRow);
|
||||
recursiveCheckExpandedStates(modelRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EntityOutlinerTreeView::checkExpandedState(const QModelIndex& current)
|
||||
{
|
||||
const bool expandState = current.data(EntityOutlinerListModel::ExpandedRole).template value<bool>();
|
||||
setExpanded(current, expandState);
|
||||
}
|
||||
|
||||
void EntityOutlinerTreeView::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
//postponing normal mouse pressed logic until mouse is released or dragged
|
||||
|
||||
+6
@@ -51,6 +51,10 @@ namespace AzToolsFramework
|
||||
Q_SIGNALS:
|
||||
void ItemDropped();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
|
||||
void rowsInserted(const QModelIndex &parent, int start, int end) override;
|
||||
|
||||
protected:
|
||||
// Qt overrides
|
||||
void mousePressEvent(QMouseEvent* event) override;
|
||||
@@ -75,6 +79,8 @@ namespace AzToolsFramework
|
||||
void ClearQueuedMouseEvent();
|
||||
|
||||
void processQueuedMousePressedEvent(QMouseEvent* event);
|
||||
void recursiveCheckExpandedStates(const QModelIndex& parent);
|
||||
void checkExpandedState(const QModelIndex& current);
|
||||
|
||||
void StartCustomDrag(const QModelIndexList& indexList, Qt::DropActions supportedActions) override;
|
||||
|
||||
|
||||
@@ -224,7 +224,6 @@ namespace AzToolsFramework
|
||||
connect(m_gui->m_objectTree, &QTreeView::expanded, this, &EntityOutlinerWidget::OnTreeItemExpanded);
|
||||
connect(m_gui->m_objectTree, &QTreeView::collapsed, this, &EntityOutlinerWidget::OnTreeItemCollapsed);
|
||||
connect(m_gui->m_objectTree, &EntityOutlinerTreeView::ItemDropped, this, &EntityOutlinerWidget::OnDropEvent);
|
||||
connect(m_listModel, &EntityOutlinerListModel::ExpandEntity, this, &EntityOutlinerWidget::OnExpandEntity);
|
||||
connect(m_listModel, &EntityOutlinerListModel::SelectEntity, this, &EntityOutlinerWidget::OnSelectEntity);
|
||||
connect(m_listModel, &EntityOutlinerListModel::EnableSelectionUpdates, this, &EntityOutlinerWidget::OnEnableSelectionUpdates);
|
||||
connect(m_listModel, &EntityOutlinerListModel::ResetFilter, this, &EntityOutlinerWidget::ClearFilter);
|
||||
@@ -972,10 +971,6 @@ namespace AzToolsFramework
|
||||
m_listModel->OnEntityCollapsed(entityId);
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::OnExpandEntity(const AZ::EntityId& entityId, bool expand)
|
||||
{
|
||||
m_gui->m_objectTree->setExpanded(GetIndexFromEntityId(entityId), expand);
|
||||
}
|
||||
|
||||
void EntityOutlinerWidget::OnSelectEntity(const AZ::EntityId& entityId, bool selected)
|
||||
{
|
||||
|
||||
@@ -155,7 +155,6 @@ namespace AzToolsFramework
|
||||
void OnTreeItemDoubleClicked(const QModelIndex& index);
|
||||
void OnTreeItemExpanded(const QModelIndex& index);
|
||||
void OnTreeItemCollapsed(const QModelIndex& index);
|
||||
void OnExpandEntity(const AZ::EntityId& entityId, bool expand);
|
||||
void OnSelectEntity(const AZ::EntityId& entityId, bool selected);
|
||||
void OnEnableSelectionUpdates(bool enable);
|
||||
void OnDropEvent();
|
||||
|
||||
Reference in New Issue
Block a user