diff main/MainWindow.cpp @ 2303:6df78d2b1b5e by-id

Work on the cancel-button
author Chris Cannam
date Mon, 15 Jul 2019 14:13:40 +0100
parents 23fea10161a6
children 1bf8b93dc006
line wrap: on
line diff
--- a/main/MainWindow.cpp	Fri Jul 05 15:35:55 2019 +0100
+++ b/main/MainWindow.cpp	Mon Jul 15 14:13:40 2019 +0100
@@ -3475,6 +3475,10 @@
 MainWindow::paneAdded(Pane *pane)
 {
     if (m_overview) m_overview->registerView(pane);
+    if (pane) {
+        connect(pane, SIGNAL(cancelButtonPressed(Layer *)),
+                this, SLOT(paneCancelButtonPressed(Layer *)));
+    }
 }    
 
 void
@@ -3490,6 +3494,31 @@
 }    
 
 void
+MainWindow::paneCancelButtonPressed(Layer *layer)
+{
+    Pane *pane = qobject_cast<Pane *>(sender());
+    bool found = false;
+    if (pane && layer) {
+        for (int i = 0; i < pane->getLayerCount(); ++i) {
+            if (pane->getLayer(i) == layer) {
+                found = true;
+                break;
+            }
+        }
+    }
+    if (!found) {
+        SVDEBUG << "MainWindow::paneCancelButtonPressed: Unknown layer in pane"
+                << endl;
+        return;
+    }
+
+    SVDEBUG << "MainWindow::paneCancelButtonPressed: Layer " << layer << endl;
+
+    m_document->removeLayerFromView(pane, layer);
+    updateMenuStates();
+}
+
+void
 MainWindow::paneDropAccepted(Pane *pane, QStringList uriList)
 {
     if (pane) m_paneStack->setCurrentPane(pane);
@@ -4146,7 +4175,7 @@
             if (auto aggregateModel = ModelById::get(aggregate)) {
                 aggregateModel->setObjectName(tr("Multiplexed audio"));
             }
-            m_document->addAggregateModel(aggregate);
+            m_document->addNonDerivedModel(aggregate);
         } else {
             ModelById::release(aggregate);
         }