changeset 344:832d246b327b

* better progress reporting in FileSource * fix set-to-default for audio dials with mappers
author Chris Cannam
date Fri, 04 Jan 2008 17:08:10 +0000
parents 1b6879d03cb6
children 8c3fb13ef11c
files layer/ImageLayer.cpp widgets/AudioDial.cpp widgets/AudioDial.h widgets/ImageDialog.cpp
diffstat 4 files changed, 31 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/layer/ImageLayer.cpp	Tue Dec 18 10:35:55 2007 +0000
+++ b/layer/ImageLayer.cpp	Fri Jan 04 17:08:10 2008 +0000
@@ -880,7 +880,7 @@
             return;
         }
 
-        FileSource *rf = new FileSource(img, true);
+        FileSource *rf = new FileSource(img, FileSource::ProgressDialog);
         if (rf->isOK()) {
             std::cerr << "ok, adding it (local filename = " << rf->getLocalFilename().toStdString() << ")" << std::endl;
             m_remoteFiles[img] = rf;
--- a/widgets/AudioDial.cpp	Tue Dec 18 10:35:55 2007 +0000
+++ b/widgets/AudioDial.cpp	Fri Jan 04 17:08:10 2008 +0000
@@ -75,6 +75,7 @@
     m_knobColor(Qt::black),
     m_meterColor(Qt::white),
     m_defaultValue(0),
+    m_defaultMappedValue(0),
     m_mappedValue(0),
     m_noMappedUpdate(false),
     m_showTooltip(true),
@@ -334,15 +335,24 @@
 void AudioDial::setDefaultValue(int defaultValue)
 {
     m_defaultValue = defaultValue;
+    if (m_rangeMapper) {
+        m_defaultMappedValue = m_rangeMapper->getValueForPosition(defaultValue);
+    }
 }
 
-
 void AudioDial::setValue(int value)
 {
     QDial::setValue(value);
     updateMappedValue(value);
 }
 
+void AudioDial::setDefaultMappedValue(float value)
+{
+    m_defaultMappedValue = value;
+    if (m_rangeMapper) {
+        m_defaultValue = m_rangeMapper->getPositionForValue(value);
+    }
+}
 
 void AudioDial::setMappedValue(float mappedValue)
 {
@@ -407,6 +417,18 @@
     }
 }
 
+void
+AudioDial::setToDefault()
+{
+    if (m_rangeMapper) {
+        setMappedValue(m_defaultMappedValue);
+        return;
+    }
+    int dv = m_defaultValue;
+    if (dv < minimum()) dv = minimum();
+    if (dv > maximum()) dv = maximum();
+    setValue(m_defaultValue);
+}
 
 // Alternate mouse behavior event handlers.
 void AudioDial::mousePressEvent(QMouseEvent *mouseEvent)
@@ -416,10 +438,7 @@
     } else if (mouseEvent->button() == Qt::MidButton ||
                ((mouseEvent->button() == Qt::LeftButton) &&
                 (mouseEvent->modifiers() & Qt::ControlModifier))) {
-	int dv = m_defaultValue;
-	if (dv < minimum()) dv = minimum();
-	if (dv > maximum()) dv = maximum();
-	setValue(m_defaultValue);
+        setToDefault();
     } else if (mouseEvent->button() == Qt::LeftButton) {
 	m_mousePressed = true;
 	m_posMouse = mouseEvent->pos();
--- a/widgets/AudioDial.h	Tue Dec 18 10:35:55 2007 +0000
+++ b/widgets/AudioDial.h	Fri Jan 04 17:08:10 2008 +0000
@@ -107,8 +107,12 @@
 
     void setValue(int value);
 
+    void setDefaultMappedValue(float mappedValue);
+
     void setMappedValue(float mappedValue);
 
+    void setToDefault();
+
 protected:
     void drawTick(QPainter &paint, float angle, int size, bool internal);
     virtual void paintEvent(QPaintEvent *);
@@ -129,6 +133,7 @@
     QColor m_meterColor;
     
     int m_defaultValue;
+    float m_defaultMappedValue;
     float m_mappedValue;
     bool m_noMappedUpdate;
 
--- a/widgets/ImageDialog.cpp	Tue Dec 18 10:35:55 2007 +0000
+++ b/widgets/ImageDialog.cpp	Fri Jan 04 17:08:10 2008 +0000
@@ -186,7 +186,7 @@
                                       tr("The URL scheme \"%1\" is not supported")
                                       .arg(url.scheme()));
             } else {
-                m_remoteFile = new FileSource(url, true);
+                m_remoteFile = new FileSource(url, FileSource::ProgressDialog);
                 m_remoteFile->waitForData();
                 if (!m_remoteFile->isOK()) {
                     QMessageBox::critical(this, tr("File download failed"),