diff widgets/PropertyStack.cpp @ 771:a964151832a7

Merge from branch tony_integration
author Chris Cannam
date Wed, 14 May 2014 09:54:34 +0100
parents b6dc57688c72
children e4773943c9c1
line wrap: on
line diff
--- a/widgets/PropertyStack.cpp	Sat Apr 12 01:07:05 2014 -0700
+++ b/widgets/PropertyStack.cpp	Wed May 14 09:54:34 2014 +0100
@@ -23,6 +23,7 @@
 #include "widgets/IconLoader.h"
 #include "base/Command.h"
 #include "widgets/CommandHistory.h"
+#include "layer/ShowLayerCommand.h"
 
 #include <QIcon>
 #include <QTabWidget>
@@ -157,9 +158,19 @@
 int
 PropertyStack::getContainerIndex(PropertyContainer *pc) const
 {
-    for (size_t i = 0; i < m_client->getPropertyContainerCount(); ++i) {
-	PropertyContainer *container = m_client->getPropertyContainer(i);
-	if (pc == container) return i;
+    // This is used to obtain an index to be passed to setCurrentIndex
+    // -- which is the index of the property container's box in our
+    // stack of boxes. That is not the same thing as the index of the
+    // container (i.e. the layer) in the view: the view reorders its
+    // containers whenever one is raised to the top, while our boxes
+    // remain in the same order. So we must find this container in the
+    // box list, not in the view.
+
+    for (size_t i = 0; i < m_boxes.size(); ++i) {
+	PropertyContainer *container = m_boxes[i]->getContainer();
+	if (pc == container) {
+            return i;
+        }
     }
 
     return false;
@@ -211,27 +222,6 @@
     repopulate();
 }
 
-class ShowLayerCommand : public QObject, public Command
-{
-public:
-    ShowLayerCommand(View *view, Layer *layer, bool show, QString name) :
-        m_view(view), m_layer(layer), m_show(show), m_name(name) { }
-    void execute() {
-        m_layer->showLayer(m_view, m_show);
-    }
-    void unexecute() {
-        m_layer->showLayer(m_view, !m_show);
-    }
-    QString getName() const {
-        return m_name;
-    }
-protected:
-    View *m_view;
-    Layer *m_layer;
-    bool m_show;
-    QString m_name;
-};
-
 void
 PropertyStack::showLayer(bool show)
 {