changeset 211:e2bbb58e6df6

Several changes related to referring to remote URLs for sessions and files: * Pull file dialog wrapper functions out from MainWindow into FileFinder * If a file referred to in a session is not found at its expected location, try a few other alternatives (same location as the session file or same location as the last audio file) before asking the user to locate it * Allow user to give a URL when locating an audio file, not just locate on the filesystem * Make wave file models remember the "original" location (e.g. URL) of the audio file, not just the actual location from which the data was loaded (e.g. local copy of that URL) -- when saving a session, use the original location so as not to refer to a temporary file * Clean up incompletely-downloaded local copies of files
author Chris Cannam
date Thu, 11 Jan 2007 13:29:58 +0000
parents a06afefe45ee
children fb8ddd00f440
files data/fileio/FileFinder.cpp data/fileio/FileFinder.h data/fileio/RemoteFile.cpp data/fileio/RemoteFile.h data/model/WaveFileModel.cpp data/model/WaveFileModel.h
diffstat 6 files changed, 537 insertions(+), 75 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/FileFinder.cpp	Wed Jan 10 17:26:39 2007 +0000
+++ b/data/fileio/FileFinder.cpp	Thu Jan 11 13:29:58 2007 +0000
@@ -15,15 +15,21 @@
 
 #include "FileFinder.h"
 #include "RemoteFile.h"
+#include "AudioFileReaderFactory.h"
+#include "DataFileReaderFactory.h"
 
 #include <QFileInfo>
 #include <QMessageBox>
 #include <QFileDialog>
+#include <QInputDialog>
+#include <QSettings>
 
+#include <iostream>
 
-FileFinder::FileFinder(QString location, QString lastKnownLocation) :
-    m_location(location),
-    m_lastKnownLocation(lastKnownLocation),
+FileFinder *
+FileFinder::m_instance = 0;
+
+FileFinder::FileFinder() :
     m_lastLocatedLocation("")
 {
 }
@@ -32,37 +38,424 @@
 {
 }
 
+FileFinder *
+FileFinder::getInstance()
+{
+    if (m_instance == 0) {
+        m_instance = new FileFinder();
+    }
+    return m_instance;
+}
+
 QString
-FileFinder::getLocation()
+FileFinder::getOpenFileName(FileType type, QString fallbackLocation)
 {
-    if (QFileInfo(m_location).exists()) return m_location;
+    QString settingsKey;
+    QString lastPath = fallbackLocation;
+    
+    QString title = tr("Select file");
+    QString filter = tr("All files (*.*)");
 
-    if (QMessageBox::question(0,
-                              QMessageBox::tr("Failed to open file"),
-                              QMessageBox::tr("Audio file \"%1\" could not be opened.\nLocate it?").arg(m_location),
-//!!!                                  QMessageBox::tr("File \"%1\" could not be opened.\nLocate it?").arg(location),
-                              QMessageBox::Ok,
-                              QMessageBox::Cancel) == QMessageBox::Ok) {
+    switch (type) {
 
-        //!!! This uses QFileDialog::getOpenFileName, while other
-        //files are located using specially built file dialogs in
-        //MainWindow::getOpenFileName -- pull out MainWindow
-        //functions into another class?
-        QString path = QFileDialog::getOpenFileName
-            (0,
-             QFileDialog::tr("Locate file \"%1\"").arg(QFileInfo(m_location).fileName()), m_location,
-             QFileDialog::tr("All files (*.*)"));
-/*!!!
-                 QFileDialog::tr("Audio files (%1)\nAll files (*.*)")
-                 .arg(AudioFileReaderFactory::getKnownExtensions()));
-*/
+    case SessionFile:
+        settingsKey = "sessionpath";
+        title = tr("Select a session file");
+        filter = tr("Sonic Visualiser session files (*.sv)\nAll files (*.*)");
+        break;
 
-        if (path != "") {
-            return path;
+    case AudioFile:
+        settingsKey = "audiopath";
+        title = "Select an audio file";
+        filter = tr("Audio files (%1)\nAll files (*.*)")
+            .arg(AudioFileReaderFactory::getKnownExtensions());
+        break;
+
+    case LayerFile:
+        settingsKey = "layerpath";
+        filter = tr("All supported files (%1)\nSonic Visualiser Layer XML files (*.svl)\nComma-separated data files (*.csv)\nSpace-separated .lab files (*.lab)\nMIDI files (*.mid)\nText files (*.txt)\nAll files (*.*)").arg(DataFileReaderFactory::getKnownExtensions());
+        break;
+
+    case SessionOrAudioFile:
+        settingsKey = "lastpath";
+        filter = tr("All supported files (*.sv %1)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nAll files (*.*)")
+            .arg(AudioFileReaderFactory::getKnownExtensions());
+        break;
+
+    case AnyFile:
+        settingsKey = "lastpath";
+        filter = tr("All supported files (*.sv %1 %2)\nSonic Visualiser session files (*.sv)\nAudio files (%1)\nLayer files (%2)\nAll files (*.*)")
+            .arg(AudioFileReaderFactory::getKnownExtensions())
+            .arg(DataFileReaderFactory::getKnownExtensions());
+        break;
+    };
+
+    if (lastPath == "") {
+        char *home = getenv("HOME");
+        if (home) lastPath = home;
+        else lastPath = ".";
+    } else if (QFileInfo(lastPath).isDir()) {
+        lastPath = QFileInfo(lastPath).canonicalPath();
+    } else {
+        lastPath = QFileInfo(lastPath).absoluteDir().canonicalPath();
+    }
+
+    QSettings settings;
+    settings.beginGroup("FileFinder");
+    lastPath = settings.value(settingsKey, lastPath).toString();
+
+    QString path = "";
+
+    // Use our own QFileDialog just for symmetry with getSaveFileName below
+
+    QFileDialog dialog;
+    dialog.setFilters(filter.split('\n'));
+    dialog.setWindowTitle(title);
+    dialog.setDirectory(lastPath);
+
+    dialog.setAcceptMode(QFileDialog::AcceptOpen);
+    dialog.setFileMode(QFileDialog::ExistingFile);
+    
+    if (dialog.exec()) {
+        QStringList files = dialog.selectedFiles();
+        if (!files.empty()) path = *files.begin();
+        
+        QFileInfo fi(path);
+        
+        if (!fi.exists()) {
+            
+            QMessageBox::critical(0, tr("File does not exist"),
+                                  tr("File \"%1\" does not exist").arg(path));
+            path = "";
+            
+        } else if (!fi.isReadable()) {
+            
+            QMessageBox::critical(0, tr("File is not readable"),
+                                  tr("File \"%1\" can not be read").arg(path));
+            path = "";
+            
+        } else if (fi.isDir()) {
+            
+            QMessageBox::critical(0, tr("Directory selected"),
+                                  tr("File \"%1\" is a directory").arg(path));
+            path = "";
+
+        } else if (!fi.isFile()) {
+            
+            QMessageBox::critical(0, tr("Non-file selected"),
+                                  tr("Path \"%1\" is not a file").arg(path));
+            path = "";
+            
+        } else if (fi.size() == 0) {
+            
+            QMessageBox::critical(0, tr("File is empty"),
+                                  tr("File \"%1\" is empty").arg(path));
+            path = "";
+        }                
+    }
+
+    if (path != "") {
+        settings.setValue(settingsKey,
+                          QFileInfo(path).absoluteDir().canonicalPath());
+    }
+    
+    return path;
+}
+
+QString
+FileFinder::getSaveFileName(FileType type, QString fallbackLocation)
+{
+    QString settingsKey;
+    QString lastPath = fallbackLocation;
+    
+    QString title = tr("Select file");
+    QString filter = tr("All files (*.*)");
+
+    switch (type) {
+
+    case SessionFile:
+        settingsKey = "savesessionpath";
+        title = tr("Select a session file");
+        filter = tr("Sonic Visualiser session files (*.sv)\nAll files (*.*)");
+        break;
+
+    case AudioFile:
+        settingsKey = "saveaudiopath";
+        title = "Select an audio file";
+        title = tr("Select a file to export to");
+        filter = tr("WAV audio files (*.wav)\nAll files (*.*)");
+        break;
+
+    case LayerFile:
+        settingsKey = "savelayerpath";
+        title = tr("Select a file to export to");
+        filter = tr("Sonic Visualiser Layer XML files (*.svl)\nComma-separated data files (*.csv)\nText files (*.txt)\nAll files (*.*)");
+        break;
+
+    case SessionOrAudioFile:
+        std::cerr << "ERROR: Internal error: FileFinder::getSaveFileName: SessionOrAudioFile cannot be used here" << std::endl;
+        abort();
+
+    case AnyFile:
+        std::cerr << "ERROR: Internal error: FileFinder::getSaveFileName: AnyFile cannot be used here" << std::endl;
+        abort();
+    };
+
+    if (lastPath == "") {
+        char *home = getenv("HOME");
+        if (home) lastPath = home;
+        else lastPath = ".";
+    } else if (QFileInfo(lastPath).isDir()) {
+        lastPath = QFileInfo(lastPath).canonicalPath();
+    } else {
+        lastPath = QFileInfo(lastPath).absoluteDir().canonicalPath();
+    }
+
+    QSettings settings;
+    settings.beginGroup("FileFinder");
+    lastPath = settings.value(settingsKey, lastPath).toString();
+
+    QString path = "";
+
+    // Use our own QFileDialog instead of static functions, as we may
+    // need to adjust the file extension based on the selected filter
+
+    QFileDialog dialog;
+    dialog.setFilters(filter.split('\n'));
+    dialog.setWindowTitle(title);
+    dialog.setDirectory(lastPath);
+
+    dialog.setAcceptMode(QFileDialog::AcceptSave);
+    dialog.setFileMode(QFileDialog::AnyFile);
+    dialog.setConfirmOverwrite(false); // we'll do that
+        
+    if (type == SessionFile) {
+        dialog.setDefaultSuffix("sv");
+    } else if (type == AudioFile) {
+        dialog.setDefaultSuffix("wav");
+    }
+
+    bool good = false;
+
+    while (!good) {
+
+        path = "";
+        
+        if (!dialog.exec()) break;
+        
+        QStringList files = dialog.selectedFiles();
+        if (files.empty()) break;
+        path = *files.begin();
+        
+        QFileInfo fi(path);
+        
+        if (type == LayerFile && fi.suffix() == "") {
+            QString expectedExtension;
+            QString selectedFilter = dialog.selectedFilter();
+            if (selectedFilter.contains(".svl")) {
+                expectedExtension = "svl";
+            } else if (selectedFilter.contains(".txt")) {
+                expectedExtension = "txt";
+            } else if (selectedFilter.contains(".csv")) {
+                expectedExtension = "csv";
+            }
+            if (expectedExtension != "") {
+                path = QString("%1.%2").arg(path).arg(expectedExtension);
+                fi = QFileInfo(path);
+            }
+        }
+        
+        if (fi.isDir()) {
+            QMessageBox::critical(0, tr("Directory selected"),
+                                  tr("File \"%1\" is a directory").arg(path));
+            continue;
+        }
+        
+        if (fi.exists()) {
+            if (QMessageBox::question(0, tr("File exists"),
+                                      tr("The file \"%1\" already exists.\nDo you want to overwrite it?").arg(path),
+                                      QMessageBox::Ok,
+                                      QMessageBox::Cancel) != QMessageBox::Ok) {
+                continue;
+            }
+        }
+        
+        good = true;
+    }
+        
+    if (path != "") {
+        settings.setValue(settingsKey,
+                          QFileInfo(path).absoluteDir().canonicalPath());
+    }
+    
+    return path;
+}
+
+void
+FileFinder::registerLastOpenedFilePath(FileType type, QString path)
+{
+    QString settingsKey;
+
+    switch (type) {
+    case SessionFile:
+        settingsKey = "sessionpath";
+        break;
+
+    case AudioFile:
+        settingsKey = "audiopath";
+        break;
+
+    case LayerFile:
+        settingsKey = "layerpath";
+        break;
+
+    case SessionOrAudioFile:
+        settingsKey = "lastpath";
+        break;
+
+    case AnyFile:
+        settingsKey = "lastpath";
+        break;
+    }
+
+    if (path != "") {
+        QSettings settings;
+        settings.beginGroup("FileFinder");
+        path = QFileInfo(path).absoluteDir().canonicalPath();
+        settings.setValue(settingsKey, path);
+        settings.setValue("lastpath", path);
+    }
+}
+    
+QString
+FileFinder::find(FileType type, QString location, QString lastKnownLocation)
+{
+    if (QFileInfo(location).exists()) return location;
+
+    if (RemoteFile::canHandleScheme(QUrl(location))) {
+        RemoteFile rf(location);
+        bool available = rf.isAvailable();
+        rf.deleteLocalFile();
+        if (available) return location;
+    }
+
+    QString foundAt = "";
+
+    if ((foundAt = findRelative(location, lastKnownLocation)) != "") {
+        return foundAt;
+    }
+
+    if ((foundAt = findRelative(location, m_lastLocatedLocation)) != "") {
+        return foundAt;
+    }
+
+    return locateInteractive(type, location);
+}
+
+QString
+FileFinder::findRelative(QString location, QString relativeTo)
+{
+    if (relativeTo == "") return "";
+
+    std::cerr << "Looking for \"" << location.toStdString() << "\" next to \""
+              << relativeTo.toStdString() << "\"..." << std::endl;
+
+    QString fileName;
+    QString resolved;
+
+    if (RemoteFile::canHandleScheme(QUrl(location))) {
+        fileName = QUrl(location).path().section('/', -1, -1,
+                                                 QString::SectionSkipEmpty);
+    } else {
+        fileName = QFileInfo(location).fileName();
+    }
+
+    if (RemoteFile::canHandleScheme(QUrl(relativeTo))) {
+        resolved = QUrl(relativeTo).resolved(fileName).toString();
+        RemoteFile rf(resolved);
+        if (!rf.isAvailable()) resolved = "";
+        std::cerr << "resolved: " << resolved.toStdString() << std::endl;
+        rf.deleteLocalFile();
+    } else {
+        resolved = QFileInfo(relativeTo).dir().filePath(fileName);
+        if (!QFileInfo(resolved).exists() ||
+            !QFileInfo(resolved).isFile() ||
+            !QFileInfo(resolved).isReadable()) {
+            resolved = "";
+        }
+    }
+            
+    return resolved;
+}
+
+QString
+FileFinder::locateInteractive(FileType type, QString thing)
+{
+    QString question;
+    if (type == AudioFile) {
+        question = tr("Audio file \"%1\" could not be opened.\nDo you want to locate it?");
+    } else {
+        question = tr("File \"%1\" could not be opened.\nDo you want to locate it?");
+    }
+
+    QString path = "";
+    bool done = false;
+
+    while (!done) {
+
+        int rv = QMessageBox::question
+            (0, 
+             tr("Failed to open file"),
+             question.arg(thing),
+             tr("Locate file..."),
+             tr("Use URL..."),
+             tr("Cancel"),
+             0, 2);
+        
+        switch (rv) {
+
+        case 0: // Locate file
+
+            if (QFileInfo(thing).dir().exists()) {
+                path = QFileInfo(thing).dir().canonicalPath();
+            }
+            
+            path = getOpenFileName(type, path);
+            done = (path != "");
+            break;
+
+        case 1: // Use URL
+        {
+            bool ok = false;
+            path = QInputDialog::getText
+                (0, tr("Use URL"),
+                 tr("Please enter the URL to use for this file:"),
+                 QLineEdit::Normal, "", &ok);
+
+            if (ok && path != "") {
+                RemoteFile rf(path);
+                if (rf.isAvailable()) {
+                    done = true;
+                } else {
+                    QMessageBox::critical
+                        (0, tr("Failed to open location"),
+                         tr("URL \"%1\" could not be opened").arg(path));
+                    path = "";
+                }
+                rf.deleteLocalFile();
+            }
+            break;
+        }
+
+        case 2: // Cancel
+            path = "";
+            done = true;
+            break;
         }
     }
 
-    return "";
+    if (path != "") m_lastLocatedLocation = path;
+    return path;
 }
 
 
--- a/data/fileio/FileFinder.h	Wed Jan 10 17:26:39 2007 +0000
+++ b/data/fileio/FileFinder.h	Thu Jan 11 13:29:58 2007 +0000
@@ -17,30 +17,38 @@
 #define _FILE_FINDER_H_
 
 #include <QString>
+#include <QObject>
 
-class FileFinder
+class FileFinder : public QObject
 {
+    Q_OBJECT
+
 public:
-    /**
-     * Find a file.
-     *
-     * "location" is what we know about where the file is supposed to
-     * be: it may be a relative path, an absolute path, a URL, or just
-     * a filename.
-     *
-     * "lastKnownLocation", if provided, is a path or URL of something
-     * that can be used as a reference point to locate it -- for
-     * example, the location of the session file that is referring to
-     * the file we're looking for.
-     */
-    FileFinder(QString location, QString lastKnownLocation = "");
     virtual ~FileFinder();
 
-    QString getLocation();
+    enum FileType {
+        SessionFile,
+        AudioFile,
+        LayerFile,
+        SessionOrAudioFile,
+        AnyFile
+    };
+
+    QString getOpenFileName(FileType type, QString fallbackLocation = "");
+    QString getSaveFileName(FileType type, QString fallbackLocation = "");
+    void registerLastOpenedFilePath(FileType type, QString path);
+
+    QString find(FileType type, QString location, QString lastKnownLocation = "");
+
+    static FileFinder *getInstance();
 
 protected:
-    QString m_location;
-    QString m_lastKnownLocation;
+    FileFinder();
+    static FileFinder *m_instance;
+
+    QString findRelative(QString location, QString relativeTo);
+    QString locateInteractive(FileType type, QString thing);
+
     QString m_lastLocatedLocation;
 };
 
--- a/data/fileio/RemoteFile.cpp	Wed Jan 10 17:26:39 2007 +0000
+++ b/data/fileio/RemoteFile.cpp	Thu Jan 11 13:29:58 2007 +0000
@@ -57,6 +57,7 @@
 
     if (scheme == "http") {
 
+        m_ok = true;
         m_http = new QHttp(url.host(), url.port(80));
         connect(m_http, SIGNAL(done(bool)), this, SLOT(done(bool)));
         connect(m_http, SIGNAL(dataReadProgress(int, int)),
@@ -64,10 +65,10 @@
         connect(m_http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
                 this, SLOT(responseHeaderReceived(const QHttpResponseHeader &)));
         m_http->get(url.path(), m_localFile);
-        m_ok = true;
 
     } else if (scheme == "ftp") {
 
+        m_ok = true;
         m_ftp = new QFtp;
         connect(m_ftp, SIGNAL(done(bool)), this, SLOT(done(bool)));
         connect(m_ftp, SIGNAL(dataTransferProgress(qint64, qint64)),
@@ -94,8 +95,6 @@
                 m_ftp->get(*i, m_localFile);
             }
         }
-
-        m_ok = true;
     }
 
     if (m_ok) {
@@ -111,10 +110,22 @@
 
 RemoteFile::~RemoteFile()
 {
+    cleanup();
+}
+
+void
+RemoteFile::cleanup()
+{
+//    std::cerr << "RemoteFile::cleanup" << std::endl;
+    m_done = true;
+    delete m_http;
+    m_http = 0;
     delete m_ftp;
-    delete m_http;
+    m_ftp = 0;
+    delete m_progressDialog;
+    m_progressDialog = 0;
     delete m_localFile;
-    delete m_progressDialog;
+    m_localFile = 0;
 }
 
 bool
@@ -127,16 +138,21 @@
 bool
 RemoteFile::isAvailable()
 {
-    while (!m_done && m_lastStatus == 0) {
+    while (m_ok && (!m_done && m_lastStatus == 0)) {
         QApplication::processEvents();
     }
-    return (m_lastStatus / 100 == 2);
+    bool available = true;
+    if (!m_ok) available = false;
+    else available = (m_lastStatus / 100 == 2);
+    std::cerr << "RemoteFile::isAvailable: " << (available ? "yes" : "no")
+              << std::endl;
+    return available;
 }
 
 void
 RemoteFile::wait()
 {
-    while (!m_done) {
+    while (m_ok && !m_done) {
         QApplication::processEvents();
     }
 }
@@ -178,30 +194,32 @@
     if (m_lastStatus / 100 >= 4) {
         m_errorString = QString("%1 %2")
             .arg(resp.statusCode()).arg(resp.reasonPhrase());
-    }
+        std::cerr << "RemoteFile::responseHeaderReceived: "
+                  << m_errorString.toStdString() << std::endl;
+    } else {
+        std::cerr << "RemoteFile::responseHeaderReceived: "
+                  << m_lastStatus << std::endl;
+    }        
 }
 
 void
 RemoteFile::dataTransferProgress(qint64 done, qint64 total)
 {
+    if (!m_progressDialog) return;
+
     int percent = int((double(done) / double(total)) * 100.0 - 0.1);
     emit progress(percent);
 
-    m_progressDialog->setValue(percent);
-    m_progressDialog->show();
+    if (percent > 0) {
+        m_progressDialog->setValue(percent);
+        m_progressDialog->show();
+    }
 }
 
 void
 RemoteFile::cancelled()
 {
-    delete m_http;
-    m_http = 0;
-    delete m_ftp;
-    m_ftp = 0;
-    delete m_progressDialog;
-    m_progressDialog = 0;
-    delete m_localFile;
-    m_localFile = 0;
+    deleteLocalFile();
     m_done = true;
     m_ok = false;
     m_errorString = tr("Download cancelled");
@@ -210,8 +228,11 @@
 void
 RemoteFile::done(bool error)
 {
+//    std::cerr << "RemoteFile::done(" << error << ")" << std::endl;
+
+    if (m_done) return;
+
     emit progress(100);
-    m_ok = !error;
 
     if (error) {
         if (m_http) {
@@ -222,25 +243,49 @@
     }
 
     if (m_lastStatus / 100 >= 4) {
-        m_ok = false;
+        error = true;
     }
 
-    delete m_localFile;
-    m_localFile = 0;
+    cleanup();
 
-    delete m_progressDialog;
-    m_progressDialog = 0;
-
-    if (m_ok) {
+    if (!error) {
         QFileInfo fi(m_localFilename);
         if (!fi.exists()) {
             m_errorString = tr("Failed to create local file %1").arg(m_localFilename);
-            m_ok = false;
+            error = true;
         } else if (fi.size() == 0) {
             m_errorString = tr("File contains no data!");
-            m_ok = false;
+            error = true;
         }
     }
+
+    if (error) {
+        deleteLocalFile();
+    }
+
+    m_ok = !error;
+    m_done = true;
+}
+
+void
+RemoteFile::deleteLocalFile()
+{
+//    std::cerr << "RemoteFile::deleteLocalFile" << std::endl;
+
+    cleanup();
+
+    if (m_localFilename == "") return;
+
+    m_fileCreationMutex.lock();
+
+    if (!QFile(m_localFilename).remove()) {
+        std::cerr << "RemoteFile::deleteLocalFile: ERROR: Failed to delete file \"" << m_localFilename.toStdString() << "\"" << std::endl;
+    } else {
+        m_localFilename = "";
+    }
+
+    m_fileCreationMutex.unlock();
+
     m_done = true;
 }
 
@@ -253,8 +298,6 @@
 QString
 RemoteFile::createLocalFile(QUrl url)
 {
-    //!!! should we actually put up dialogs for these errors? or propagate an exception?
-    
     QDir dir;
     try {
         dir = TempDirectory::getInstance()->getSubDirectoryPath("download");
--- a/data/fileio/RemoteFile.h	Wed Jan 10 17:26:39 2007 +0000
+++ b/data/fileio/RemoteFile.h	Thu Jan 11 13:29:58 2007 +0000
@@ -45,6 +45,8 @@
     QString getLocalFilename() const;
     QString getErrorString() const;
 
+    void deleteLocalFile();
+
     static bool canHandleScheme(QUrl url);
 
 signals:
@@ -71,6 +73,8 @@
     QProgressDialog *m_progressDialog;
     QTimer m_progressShowTimer;
 
+    void cleanup();
+
     QString createLocalFile(QUrl url);
 
     static QMutex m_fileCreationMutex;
--- a/data/model/WaveFileModel.cpp	Wed Jan 10 17:26:39 2007 +0000
+++ b/data/model/WaveFileModel.cpp	Thu Jan 11 13:29:58 2007 +0000
@@ -49,6 +49,19 @@
     if (isOK()) fillCache();
 }
 
+WaveFileModel::WaveFileModel(QString path, QString originalLocation) :
+    m_path(originalLocation),
+    m_myReader(true),
+    m_fillThread(0),
+    m_updateTimer(0),
+    m_lastFillExtent(0),
+    m_exiting(false)
+{
+    m_reader = AudioFileReaderFactory::createReader(path);
+    setObjectName(QFileInfo(originalLocation).fileName());
+    if (isOK()) fillCache();
+}
+
 WaveFileModel::WaveFileModel(QString path, AudioFileReader *reader) :
     m_path(path),
     m_myReader(false),
--- a/data/model/WaveFileModel.h	Wed Jan 10 17:26:39 2007 +0000
+++ b/data/model/WaveFileModel.h	Thu Jan 11 13:29:58 2007 +0000
@@ -33,7 +33,8 @@
 
 public:
     WaveFileModel(QString path);
-    WaveFileModel(QString path, AudioFileReader *reader);
+    WaveFileModel(QString path, QString originalLocation);
+    WaveFileModel(QString originalLocation, AudioFileReader *reader);
     ~WaveFileModel();
 
     bool isOK() const;