Mercurial > hg > svgui
comparison widgets/InteractiveFileFinder.cpp @ 586:1ae54a29e59e
Merge from debug-output branch
author | Chris Cannam |
---|---|
date | Tue, 14 Jun 2011 14:48:29 +0100 |
parents | f4960f8ce798 |
children | 4806715f7a19 |
comparison
equal
deleted
inserted
replaced
583:4c484636d5ec | 586:1ae54a29e59e |
---|---|
33 InteractiveFileFinder::m_instance; | 33 InteractiveFileFinder::m_instance; |
34 | 34 |
35 InteractiveFileFinder::InteractiveFileFinder() : | 35 InteractiveFileFinder::InteractiveFileFinder() : |
36 m_lastLocatedLocation("") | 36 m_lastLocatedLocation("") |
37 { | 37 { |
38 std::cerr << "Registering interactive file finder" << std::endl; | 38 DEBUG << "Registering interactive file finder" << endl; |
39 FileFinder::registerFileFinder(this); | 39 FileFinder::registerFileFinder(this); |
40 } | 40 } |
41 | 41 |
42 InteractiveFileFinder::~InteractiveFileFinder() | 42 InteractiveFileFinder::~InteractiveFileFinder() |
43 { | 43 { |
282 if (files.empty()) break; | 282 if (files.empty()) break; |
283 path = *files.begin(); | 283 path = *files.begin(); |
284 | 284 |
285 QFileInfo fi(path); | 285 QFileInfo fi(path); |
286 | 286 |
287 std::cerr << "type = " << type << ", suffix = " << fi.suffix().toStdString() << std::endl; | 287 std::cerr << "type = " << type << ", suffix = " << fi.suffix() << std::endl; |
288 | 288 |
289 if ((type == LayerFile || type == LayerFileNoMidi) | 289 if ((type == LayerFile || type == LayerFileNoMidi) |
290 && fi.suffix() == "") { | 290 && fi.suffix() == "") { |
291 QString expectedExtension; | 291 QString expectedExtension; |
292 QString selectedFilter = dialog.selectedFilter(); | 292 QString selectedFilter = dialog.selectedFilter(); |
299 } else if (selectedFilter.contains(".mid")) { | 299 } else if (selectedFilter.contains(".mid")) { |
300 expectedExtension = "mid"; | 300 expectedExtension = "mid"; |
301 } else if (selectedFilter.contains(".ttl")) { | 301 } else if (selectedFilter.contains(".ttl")) { |
302 expectedExtension = "ttl"; | 302 expectedExtension = "ttl"; |
303 } | 303 } |
304 std::cerr << "expected extension = " << expectedExtension.toStdString() << std::endl; | 304 std::cerr << "expected extension = " << expectedExtension << std::endl; |
305 if (expectedExtension != "") { | 305 if (expectedExtension != "") { |
306 path = QString("%1.%2").arg(path).arg(expectedExtension); | 306 path = QString("%1.%2").arg(path).arg(expectedExtension); |
307 fi = QFileInfo(path); | 307 fi = QFileInfo(path); |
308 } | 308 } |
309 } | 309 } |
381 QString | 381 QString |
382 InteractiveFileFinder::find(FileType type, QString location, QString lastKnownLocation) | 382 InteractiveFileFinder::find(FileType type, QString location, QString lastKnownLocation) |
383 { | 383 { |
384 if (FileSource::canHandleScheme(location)) { | 384 if (FileSource::canHandleScheme(location)) { |
385 if (FileSource(location).isAvailable()) { | 385 if (FileSource(location).isAvailable()) { |
386 std::cerr << "InteractiveFileFinder::find: ok, it's available... returning" << std::endl; | 386 DEBUG << "InteractiveFileFinder::find: ok, it's available... returning" << endl; |
387 return location; | 387 return location; |
388 } | 388 } |
389 } | 389 } |
390 | 390 |
391 if (QFileInfo(location).exists()) return location; | 391 if (QFileInfo(location).exists()) return location; |
406 QString | 406 QString |
407 InteractiveFileFinder::findRelative(QString location, QString relativeTo) | 407 InteractiveFileFinder::findRelative(QString location, QString relativeTo) |
408 { | 408 { |
409 if (relativeTo == "") return ""; | 409 if (relativeTo == "") return ""; |
410 | 410 |
411 std::cerr << "Looking for \"" << location.toStdString() << "\" next to \"" | 411 DEBUG << "Looking for \"" << location << "\" next to \"" |
412 << relativeTo.toStdString() << "\"..." << std::endl; | 412 << relativeTo << "\"..." << endl; |
413 | 413 |
414 QString fileName; | 414 QString fileName; |
415 QString resolved; | 415 QString resolved; |
416 | 416 |
417 if (FileSource::isRemote(location)) { | 417 if (FileSource::isRemote(location)) { |
425 } | 425 } |
426 | 426 |
427 if (FileSource::isRemote(relativeTo)) { | 427 if (FileSource::isRemote(relativeTo)) { |
428 resolved = QUrl(relativeTo).resolved(fileName).toString(); | 428 resolved = QUrl(relativeTo).resolved(fileName).toString(); |
429 if (!FileSource(resolved).isAvailable()) resolved = ""; | 429 if (!FileSource(resolved).isAvailable()) resolved = ""; |
430 std::cerr << "resolved: " << resolved.toStdString() << std::endl; | 430 std::cerr << "resolved: " << resolved << std::endl; |
431 } else { | 431 } else { |
432 if (QUrl(relativeTo).scheme() == "file") { | 432 if (QUrl(relativeTo).scheme() == "file") { |
433 relativeTo = QUrl(relativeTo).toLocalFile(); | 433 relativeTo = QUrl(relativeTo).toLocalFile(); |
434 } | 434 } |
435 resolved = QFileInfo(relativeTo).dir().filePath(fileName); | 435 resolved = QFileInfo(relativeTo).dir().filePath(fileName); |