From ed859fadf5b33606d5253ec8118f2cd46492d198 Mon Sep 17 00:00:00 2001 From: Tats Date: Fri, 12 Feb 2016 12:16:11 -0500 Subject: [PATCH] Fix bug: solo was not working. --- MappingManager.cpp | 25 +++++++++++++++++++++++++ MappingManager.h | 4 ++++ ShapeGraphicsItem.cpp | 4 ++++ ShapeGraphicsItem.h | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/MappingManager.cpp b/MappingManager.cpp index b421f3f..e48a767 100644 --- a/MappingManager.cpp +++ b/MappingManager.cpp @@ -145,6 +145,31 @@ QVector MappingManager::getVisibleMappings() const return visible; } +/// Returns true iff the mapping is visible. +bool MappingManager::mappingIsVisible(Mapping::ptr mapping) const +{ + // Solo mappings are always visible. + if (mapping->isSolo()) + return true; + + // Non-solo invisible mappings are always invisible. + else if (!mapping->isVisible()) + return false; + + // Mapping is non-solo yet visible: check if another mapping is solo (which would thus make it invisible). + else + { + for (QVector::const_iterator it = mappingVector.begin(); it != mappingVector.end(); ++it) + { + if ((*it)->isSolo()) + return false; + } + + // Mapping is non-solo yet visible and there are no solo mappings. + return true; + } +} + void MappingManager::reorderMappings(QVector mappingIds) { // Both vector needs to have the same size. diff --git a/MappingManager.h b/MappingManager.h index 2f2a9c0..f81158f 100644 --- a/MappingManager.h +++ b/MappingManager.h @@ -100,8 +100,12 @@ public: /// Reorders the mappings according to given list of uids. QVector needs to void reorderMappings(QVector mappingIds); + /// Returns the ordered list of visible mappings, using both the "visible" and "solo" properties. QVector getVisibleMappings() const; + /// Returns true iff the mapping is visible. + bool mappingIsVisible(Mapping::ptr mapping) const; + void clearAll(); }; diff --git a/ShapeGraphicsItem.cpp b/ShapeGraphicsItem.cpp index c935be7..e47350c 100644 --- a/ShapeGraphicsItem.cpp +++ b/ShapeGraphicsItem.cpp @@ -38,6 +38,10 @@ bool ShapeGraphicsItem::isMappingCurrent() const { return MainWindow::instance()->getCurrentMappingId() == getMapping()->getId(); } +bool ShapeGraphicsItem::isMappingVisible() const { + return MainWindow::instance()->getMappingManager().mappingIsVisible(getMapping()); +} + void ShapeGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { diff --git a/ShapeGraphicsItem.h b/ShapeGraphicsItem.h index 34541bb..9fda9a1 100644 --- a/ShapeGraphicsItem.h +++ b/ShapeGraphicsItem.h @@ -75,7 +75,7 @@ public: bool isMappingCurrent() const; /// Returns whether the mapping this shape is associated should be visible. - bool isMappingVisible() const { return getMapping()->isVisible(); } + bool isMappingVisible() const; /// Returns the bounding rectangle of this item. virtual QRectF boundingRect() const { return shape().boundingRect(); }