comparison data/fileio/FileFinder.cpp @ 210:a06afefe45ee

* Cancel when downloading file * Handle status codes (404 etc) * Add RemoteFile::isAvailable * Start on FileFinder for looking up files referred to in distant sessions
author Chris Cannam
date Wed, 10 Jan 2007 17:26:39 +0000
parents
children e2bbb58e6df6
comparison
equal deleted inserted replaced
209:6576a208e8e7 210:a06afefe45ee
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2007 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #include "FileFinder.h"
17 #include "RemoteFile.h"
18
19 #include <QFileInfo>
20 #include <QMessageBox>
21 #include <QFileDialog>
22
23
24 FileFinder::FileFinder(QString location, QString lastKnownLocation) :
25 m_location(location),
26 m_lastKnownLocation(lastKnownLocation),
27 m_lastLocatedLocation("")
28 {
29 }
30
31 FileFinder::~FileFinder()
32 {
33 }
34
35 QString
36 FileFinder::getLocation()
37 {
38 if (QFileInfo(m_location).exists()) return m_location;
39
40 if (QMessageBox::question(0,
41 QMessageBox::tr("Failed to open file"),
42 QMessageBox::tr("Audio file \"%1\" could not be opened.\nLocate it?").arg(m_location),
43 //!!! QMessageBox::tr("File \"%1\" could not be opened.\nLocate it?").arg(location),
44 QMessageBox::Ok,
45 QMessageBox::Cancel) == QMessageBox::Ok) {
46
47 //!!! This uses QFileDialog::getOpenFileName, while other
48 //files are located using specially built file dialogs in
49 //MainWindow::getOpenFileName -- pull out MainWindow
50 //functions into another class?
51 QString path = QFileDialog::getOpenFileName
52 (0,
53 QFileDialog::tr("Locate file \"%1\"").arg(QFileInfo(m_location).fileName()), m_location,
54 QFileDialog::tr("All files (*.*)"));
55 /*!!!
56 QFileDialog::tr("Audio files (%1)\nAll files (*.*)")
57 .arg(AudioFileReaderFactory::getKnownExtensions()));
58 */
59
60 if (path != "") {
61 return path;
62 }
63 }
64
65 return "";
66 }
67
68