summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-05-25 17:59:13 +0300
committerTomi Korpipää <tomi.korpipaa@qt.io>2018-05-28 05:27:10 +0000
commitb1c6a6628cffc1a5a89bd9d82240020dac2dcbb9 (patch)
treeb6dc9318b4eaa4926e090a99b326732ca470afdc
parent34b5fe0124dd1ce2872c68e071ef392ebf9cd408 (diff)
Fix filtering
Fixed various filtering issues: - Expansion arrow shouldn't show if no visible children - Filtering should be up-to-date when slide is changed - Expanding an item should not show filtered out children Task-number: QT3DS-1764 Change-Id: Ia5573a5dc0c5e5e0e7d6fa0a4b4d4913190301d6 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp27
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h1
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp10
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp44
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h4
5 files changed, 60 insertions, 26 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp
index f02c0c4a..cf6aa893 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp
@@ -284,40 +284,23 @@ void RowManager::updateRulerDuration()
void RowManager::updateFiltering(RowTree *row)
{
- if (!row) { // update all rows
- RowTree *row_i;
- for (int i = 1; i < m_layoutTree->count(); ++i) {
- row_i = static_cast<RowTree *>(m_layoutTree->itemAt(i)->graphicsItem());
- updateRowFilter(row_i);
- }
- } else {
- updateRowFilterRecursive(row);
- }
+ if (!row) // update all rows
+ row = static_cast<RowTree *>(m_layoutTree->itemAt(1));
+ updateRowFilterRecursive(row);
}
void RowManager::updateRowFilterRecursive(RowTree *row)
{
- updateRowFilter(row);
+ row->updateFilter();
if (!row->empty()) {
const auto childRows = row->childRows();
for (auto child : childRows)
updateRowFilterRecursive(child);
+ row->updateArrowVisibility();
}
}
-void RowManager::updateRowFilter(RowTree *row)
-{
- bool parentOk = !row->parentRow()|| row->parentRow()->isVisible();
- bool shyOk = !row->shy() || !m_scene->treeHeader()->filterShy();
- bool visibleOk = row->visible() || !m_scene->treeHeader()->filterHidden();
- bool lockOk = !row->locked() || !m_scene->treeHeader()->filterLocked();
- bool expandOk = !row->expandHidden();
-
- row->setVisible(parentOk && shyOk && visibleOk && lockOk && expandOk);
- row->rowTimeline()->setVisible(row->isVisible());
-}
-
void RowManager::deleteRow(RowTree *row)
{
if (row && row->rowType() != OBJTYPE_SCENE) {
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h
index b7ce64ca..56021889 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.h
@@ -77,7 +77,6 @@ private:
int getLastChildIndex(RowTree *row, int index = -1);
bool validIndex(int idx) const;
void deleteRowRecursive(RowTree *row);
- void updateRowFilter(RowTree *row);
void updateRowFilterRecursive(RowTree *row);
void createRowsFromBindingRecursive(ITimelineItemBinding *binding,
RowTree *parentRow = nullptr);
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
index eb7f3553..2bbc3aa6 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineWidget.cpp
@@ -681,6 +681,7 @@ void TimelineWidget::onAsyncUpdate()
m_navigationBar->updateNavigationItems(m_translationManager->GetBreadCrumbProvider());
m_graphicsScene->updateSnapSteps();
m_fullReconstruct = false;
+ m_graphicsScene->rowManager()->updateFiltering();
onSelectionChange(doc->GetSelectedValue());
} else {
if (!m_moveMap.isEmpty()) {
@@ -723,6 +724,7 @@ void TimelineWidget::onAsyncUpdate()
const SDataModelSceneAsset &asset = m_bridge->GetSceneAsset();
qt3dsdm::Qt3DSDMPropertyHandle nameProp = m_bridge->GetNameProperty();
const auto instances = m_dirtyProperties.keys();
+ QSet<RowTree *> updateArrowParents;
for (int instance : instances) {
bool filterProperty = false;
bool timeProperty = false;
@@ -742,14 +744,20 @@ void TimelineWidget::onAsyncUpdate()
if (row) {
if (timeProperty)
row->rowTimeline()->updateDurationFromBinding();
- if (filterProperty)
+ if (filterProperty) {
row->updateFromBinding();
+ m_graphicsScene->rowManager()->updateFiltering(row);
+ // Filtering changes to children affect arrow visibility in parents
+ updateArrowParents.insert(row->parentRow());
+ }
if (nameProperty)
row->updateLabel();
}
}
}
}
+ for (RowTree *row : qAsConst(updateArrowParents))
+ row->updateArrowVisibility();
}
}
m_dirtyProperties.clear();
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
index 5e587653..716691fd 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp
@@ -35,6 +35,7 @@
#include "Bindings/ITimelineItemBinding.h"
#include "Bindings/Qt3DSDMTimelineItemBinding.h"
#include "Qt3DSString.h"
+#include "TreeHeader.h"
#include <QtGui/qpainter.h>
#include "QtGui/qtextcursor.h"
@@ -202,7 +203,7 @@ void RowTree::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
// expand/collapse arrow
static const QPixmap pixArrow = QPixmap(":/images/arrow.png");
static const QPixmap pixArrowDown = QPixmap(":/images/arrow_down.png");
- if (!m_childRows.empty() || !m_childProps.empty())
+ if (m_arrowVisible)
painter->drawPixmap(m_rectArrow, expanded() ? pixArrowDown : pixArrow);
// Row type icon
@@ -481,6 +482,41 @@ int RowTree::getLastChildIndex(bool isProperty) const
return index;
}
+void RowTree::updateArrowVisibility()
+{
+ bool oldVisibility = m_arrowVisible;
+ if (m_childRows.empty() && m_childProps.empty()) {
+ m_arrowVisible = false;
+ } else {
+ if (m_childProps.empty()) {
+ m_arrowVisible = false;
+ for (RowTree *row : qAsConst(m_childRows)) {
+ if (!row->m_filtered) {
+ m_arrowVisible = true;
+ break;
+ }
+ }
+ } else {
+ m_arrowVisible = true;
+ }
+ }
+ if (oldVisibility != m_arrowVisible)
+ update();
+}
+
+void RowTree::updateFilter()
+{
+ bool parentOk = !m_parentRow || m_parentRow->isVisible();
+ bool shyOk = !m_shy || !m_scene->treeHeader()->filterShy();
+ bool visibleOk = m_visible || !m_scene->treeHeader()->filterHidden();
+ bool lockOk = !m_locked || !m_scene->treeHeader()->filterLocked();
+ bool expandOk = !expandHidden();
+
+ m_filtered = !(shyOk && visibleOk && lockOk);
+ setVisible(parentOk && shyOk && visibleOk && lockOk && expandOk);
+ m_rowTimeline->setVisible(isVisible());
+}
+
int RowTree::getCountDecendentsRecursive() const
{
int num = m_childProps.count();
@@ -540,6 +576,7 @@ void RowTree::addChildAt(RowTree *child, int index)
// update indices
updateIndexInLayout = std::min(updateIndexInLayout, child->m_indexInLayout);
updateIndices(true, child->m_index + 1, updateIndexInLayout, child->isProperty());
+ updateArrowVisibility();
}
int RowTree::addToLayout(int indexInLayout)
@@ -588,6 +625,7 @@ void RowTree::removeChild(RowTree *child)
child->m_parentRow = nullptr;
updateIndices(false, child->m_index, child->m_indexInLayout, child->isProperty());
+ updateArrowVisibility();
}
}
@@ -710,7 +748,7 @@ void RowTree::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
TreeControlType RowTree::getClickedControl(const QPointF &scenePos)
{
QPointF p = mapFromScene(scenePos.x(), scenePos.y());
- if (!empty() && m_rectArrow.contains(p.x(), p.y()) && !m_locked) {
+ if (m_arrowVisible && m_rectArrow.contains(p.x(), p.y()) && !m_locked) {
updateExpandStatus(m_expandState == ExpandState::Expanded ? ExpandState::Collapsed
: ExpandState::Expanded, false);
update();
@@ -778,6 +816,8 @@ void RowTree::updateExpandStatus(ExpandState state, bool animate)
child->updateExpandStatus(ExpandState::HiddenExpanded);
}
}
+
+ updateFilter();
}
void RowTree::updateLockRecursive(bool state)
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
index e2147cce..100c6c40 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h
@@ -121,6 +121,8 @@ public:
ITimelineItemBinding *getBinding() const;
void updateExpandStatus(ExpandState state, bool animate = true);
+ void updateArrowVisibility();
+ void updateFilter();
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
@@ -153,6 +155,8 @@ private:
bool m_isProperty = false;
bool m_isPropertyExpanded = false;
bool m_master = false;
+ bool m_filtered = false;
+ bool m_arrowVisible = false;
ExpandState m_expandState = ExpandState::HiddenCollapsed;
TimelineGraphicsScene *m_scene;
RowTreeLabelItem m_labelItem;