Chris@210: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@210: Chris@210: /* Chris@210: Sonic Visualiser Chris@210: An audio file viewer and annotation editor. Chris@210: Centre for Digital Music, Queen Mary, University of London. Chris@210: This file copyright 2007 QMUL. Chris@210: Chris@210: This program is free software; you can redistribute it and/or Chris@210: modify it under the terms of the GNU General Public License as Chris@210: published by the Free Software Foundation; either version 2 of the Chris@210: License, or (at your option) any later version. See the file Chris@210: COPYING included with this distribution for more information. Chris@210: */ Chris@210: Chris@210: #include "FileFinder.h" Chris@210: #include "RemoteFile.h" Chris@210: Chris@210: #include Chris@210: #include Chris@210: #include Chris@210: Chris@210: Chris@210: FileFinder::FileFinder(QString location, QString lastKnownLocation) : Chris@210: m_location(location), Chris@210: m_lastKnownLocation(lastKnownLocation), Chris@210: m_lastLocatedLocation("") Chris@210: { Chris@210: } Chris@210: Chris@210: FileFinder::~FileFinder() Chris@210: { Chris@210: } Chris@210: Chris@210: QString Chris@210: FileFinder::getLocation() Chris@210: { Chris@210: if (QFileInfo(m_location).exists()) return m_location; Chris@210: Chris@210: if (QMessageBox::question(0, Chris@210: QMessageBox::tr("Failed to open file"), Chris@210: QMessageBox::tr("Audio file \"%1\" could not be opened.\nLocate it?").arg(m_location), Chris@210: //!!! QMessageBox::tr("File \"%1\" could not be opened.\nLocate it?").arg(location), Chris@210: QMessageBox::Ok, Chris@210: QMessageBox::Cancel) == QMessageBox::Ok) { Chris@210: Chris@210: //!!! This uses QFileDialog::getOpenFileName, while other Chris@210: //files are located using specially built file dialogs in Chris@210: //MainWindow::getOpenFileName -- pull out MainWindow Chris@210: //functions into another class? Chris@210: QString path = QFileDialog::getOpenFileName Chris@210: (0, Chris@210: QFileDialog::tr("Locate file \"%1\"").arg(QFileInfo(m_location).fileName()), m_location, Chris@210: QFileDialog::tr("All files (*.*)")); Chris@210: /*!!! Chris@210: QFileDialog::tr("Audio files (%1)\nAll files (*.*)") Chris@210: .arg(AudioFileReaderFactory::getKnownExtensions())); Chris@210: */ Chris@210: Chris@210: if (path != "") { Chris@210: return path; Chris@210: } Chris@210: } Chris@210: Chris@210: return ""; Chris@210: } Chris@210: Chris@210: