diff data/fileio/FileSource.h @ 357:b92513201610

* 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 1d656dcda8ef
children 183ee2a55fc7
line wrap: on
line diff
--- a/data/fileio/FileSource.h	Mon Dec 17 12:32:28 2007 +0000
+++ b/data/fileio/FileSource.h	Fri Jan 04 17:08:10 2008 +0000
@@ -28,6 +28,7 @@
 class QFile;
 class QProgressDialog;
 class QHttpResponseHeader;
+class ProgressPrinter;
 
 /**
  * FileSource is a class used to refer to the contents of a file that
@@ -62,19 +63,36 @@
 
 public:
 
+    enum ShowProgressType {
+        ProgressNone,
+        ProgressDialog,
+        ProgressToConsole
+    };
+
     /**
      * Construct a FileSource using the given local file path or URL.
-     * The URL may be raw or encoded.  If showProgress is true, a
-     * progress dialog will be shown for any network transfers.
+     * The URL may be raw or encoded.
+     *
+     * If progressType is ProgressDialog, a progress dialog will be
+     * shown for any network transfers; if it is ProgressToConsole, a
+     * progress indication will be sent to the console.
+     * Note that the progress() signal will also be emitted regularly
+     * during retrieval, even if progressType is ProgressNone.
      */
-    FileSource(QString fileOrUrl, bool showProgress = false);
+    FileSource(QString fileOrUrl,
+               ShowProgressType progressType = ProgressNone);
 
     /**
-     * Construct a FileSource using the given remote URL.  If
-     * showProgress is true, a progress dialog will be shown for any
-     * network transfers.
+     * Construct a FileSource using the given remote URL.
+     *
+     * If progressType is ProgressDialog, a progress dialog will be
+     * shown for any network transfers; if it is ProgressToConsole, a
+     * progress indication will be sent to the console.
+     * Note that the progress() signal also will be emitted regularly
+     * during retrieval, even if progressType is ProgressNone.
      */
-    FileSource(QUrl url, bool showProgress = false);
+    FileSource(QUrl url,
+               ShowProgressType progressType = ProgressNone);
 
     FileSource(const FileSource &);
 
@@ -212,6 +230,8 @@
     bool m_remote;
     bool m_done;
     bool m_leaveLocalFile;
+    ShowProgressType m_progressType;
+    ProgressPrinter *m_progressPrinter;
     QProgressDialog *m_progressDialog;
     QTimer m_progressShowTimer;
 
@@ -222,7 +242,7 @@
     static QMutex m_mapMutex;
     bool m_refCounted;
 
-    void init(bool showProgress);
+    void init();
     void initHttp();
     void initFtp();
 
@@ -237,19 +257,4 @@
     static int m_count;
 };
 
-class FileSourceProgressPrinter : public QObject
-{
-    Q_OBJECT
-
-public:
-    FileSourceProgressPrinter();
-    virtual ~FileSourceProgressPrinter();
-    
-public slots:
-    void progress(int);
-
-protected:
-    int m_lastProgress;
-};
-
 #endif