diff view/View.cpp @ 1459:42c87368287c

Merge from branch single-point
author Chris Cannam
date Fri, 17 May 2019 10:02:52 +0100
parents 009f22e03bf6
children 84c4ddb38415
line wrap: on
line diff
--- a/view/View.cpp	Wed Apr 24 11:29:53 2019 +0100
+++ b/view/View.cpp	Fri May 17 10:02:52 2019 +0100
@@ -50,6 +50,7 @@
 
 //#define DEBUG_VIEW 1
 //#define DEBUG_VIEW_WIDGET_PAINT 1
+//#define DEBUG_PROGRESS_STUFF 1
 
 View::View(QWidget *w, bool showProgress) :
     QFrame(w),
@@ -234,7 +235,7 @@
     for (LayerList::const_iterator i = m_layerStack.begin();
          i != m_layerStack.end(); ++i) { 
         if ((*i)->needsTextLabelHeight()) {
-            sortedLayers[getObjectExportId(*i)] = *i;
+            sortedLayers[(*i)->getExportId()] = *i;
         }
     }
 
@@ -1736,9 +1737,21 @@
 void
 View::checkProgress(void *object)
 {
-    if (!m_showProgress) return;
-
+    if (!m_showProgress) {
+#ifdef DEBUG_PROGRESS_STUFF
+        SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
+               << "m_showProgress is off" << endl;
+#endif
+        return;
+    }
+
+    QSettings settings;
+    settings.beginGroup("View");
+    bool showCancelButton = settings.value("showcancelbuttons", true).toBool();
+    settings.endGroup();
+    
     int ph = height();
+    bool found = false;
 
     for (ProgressMap::iterator i = m_progressBars.begin();
          i != m_progressBars.end(); ++i) {
@@ -1748,6 +1761,18 @@
 
         if (i->first == object) {
 
+            found = true;
+
+            if (i->first->isLayerDormant(this)) {
+                // A dormant (invisible) layer can still be busy
+                // generating, but we don't usually want to indicate
+                // it because it probably means it's a duplicate of a
+                // visible layer
+                cancel->hide();
+                pb->hide();
+                continue;
+            }
+            
             // The timer is used to test for stalls.  If the progress
             // bar does not get updated for some length of time, the
             // timer prompts it to go back into "indeterminate" mode
@@ -1757,6 +1782,12 @@
             QString text = i->first->getPropertyContainerName();
             QString error = i->first->getError(this);
 
+#ifdef DEBUG_PROGRESS_STUFF
+            SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
+                   << "found progress bar " << pb << " for layer at height " << ph
+                   << ": completion = " << completion << endl;
+#endif
+
             if (error != "" && error != m_lastError) {
                 QMessageBox::critical(this, tr("Layer rendering error"), error);
                 m_lastError = error;
@@ -1778,7 +1809,12 @@
                      (wfm = dynamic_cast<RangeSummarisableTimeValueModel *>
                       (model->getSourceModel())))) {
                     completion = wfm->getAlignmentCompletion();
-//                    SVDEBUG << "View::checkProgress: Alignment completion = " << completion << endl;
+
+#ifdef DEBUG_PROGRESS_STUFF
+                    SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
+                           << "alignment completion = " << completion << endl;
+#endif
+                
                     if (completion < 100) {
                         text = tr("Alignment");
                     }
@@ -1796,21 +1832,29 @@
 
             } else {
 
-//                cerr << "progress = " << completion << endl;
-
                 if (!pb->isVisible()) {
                     i->second.lastCheck = 0;
                     timer->setInterval(2000);
                     timer->start();
                 }
 
-                int scaled20 = scalePixelSize(20);
-
-                cancel->move(0, ph - pb->height()/2 - scaled20/2);
-                cancel->show();
-
-                pb->setValue(completion);
-                pb->move(scaled20, ph - pb->height());
+                if (showCancelButton) {
+                
+                    int scaled20 = scalePixelSize(20);
+
+                    cancel->move(0, ph - pb->height()/2 - scaled20/2);
+                    cancel->show();
+
+                    pb->setValue(completion);
+                    pb->move(scaled20, ph - pb->height());
+
+                } else {
+
+                    cancel->hide();
+
+                    pb->setValue(completion);
+                    pb->move(0, ph - pb->height());
+                }
 
                 pb->show();
                 pb->update();
@@ -1823,6 +1867,14 @@
             }
         }
     }
+
+    if (!found) {
+#ifdef DEBUG_PROGRESS_STUFF
+        SVCERR << "View[" << this << "]::checkProgress(" << object << "): "
+               << "failed to find layer " << object << " in progress map"
+               << endl;
+#endif
+    }
 }
 
 void
@@ -1831,9 +1883,16 @@
     QObject *s = sender();
     QTimer *t = qobject_cast<QTimer *>(s);
     if (!t) return;
+
     for (ProgressMap::iterator i =  m_progressBars.begin();
          i != m_progressBars.end(); ++i) {
+
         if (i->second.checkTimer == t) {
+
+#ifdef DEBUG_PROGRESS_STUFF
+            SVCERR << "View[" << this << "]::progressCheckStalledTimerElapsed for layer " << i->first << endl;
+#endif
+    
             int value = i->second.bar->value();
             if (value > 0 && value == i->second.lastCheck) {
                 i->second.bar->setMaximum(0); // indeterminate