comparison main/OSCHandler.cpp @ 437:9de86c1b980e

Merge from debug-output branch
author Chris Cannam
date Tue, 14 Jun 2011 14:50:08 +0100
parents 5f22e0bbe4ba ae68fc09bf16
children 868f73825b37
comparison
equal deleted inserted replaced
428:5f22e0bbe4ba 437:9de86c1b980e
33 #include <QFileInfo> 33 #include <QFileInfo>
34 34
35 void 35 void
36 MainWindow::handleOSCMessage(const OSCMessage &message) 36 MainWindow::handleOSCMessage(const OSCMessage &message)
37 { 37 {
38 std::cerr << "MainWindow::handleOSCMessage: thread id = " 38 DEBUG << "MainWindow::handleOSCMessage: thread id = "
39 << QThread::currentThreadId() << std::endl; 39 << QThread::currentThreadId() << endl;
40 40
41 // This large function should really be abstracted out. 41 // This large function should really be abstracted out.
42 42
43 if (message.getMethod() == "open") { 43 if (message.getMethod() == "open") {
44 44
45 if (message.getArgCount() == 1 && 45 if (message.getArgCount() == 1 &&
46 message.getArg(0).canConvert(QVariant::String)) { 46 message.getArg(0).canConvert(QVariant::String)) {
47 QString path = message.getArg(0).toString(); 47 QString path = message.getArg(0).toString();
48 if (open(path, ReplaceMainModel) != FileOpenSucceeded) { 48 if (open(path, ReplaceMainModel) != FileOpenSucceeded) {
49 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \"" 49 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
50 << path.toStdString() << "\"" << std::endl; 50 << path << "\"" << std::endl;
51 } 51 }
52 //!!! we really need to spin here and not return until the 52 //!!! we really need to spin here and not return until the
53 // file has been completely decoded... 53 // file has been completely decoded...
54 } 54 }
55 55
58 if (message.getArgCount() == 1 && 58 if (message.getArgCount() == 1 &&
59 message.getArg(0).canConvert(QVariant::String)) { 59 message.getArg(0).canConvert(QVariant::String)) {
60 QString path = message.getArg(0).toString(); 60 QString path = message.getArg(0).toString();
61 if (open(path, CreateAdditionalModel) != FileOpenSucceeded) { 61 if (open(path, CreateAdditionalModel) != FileOpenSucceeded) {
62 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \"" 62 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
63 << path.toStdString() << "\"" << std::endl; 63 << path << "\"" << std::endl;
64 } 64 }
65 } 65 }
66 66
67 } else if (message.getMethod() == "recent" || 67 } else if (message.getMethod() == "recent" ||
68 message.getMethod() == "last") { 68 message.getMethod() == "last") {
75 } 75 }
76 std::vector<QString> recent = m_recentFiles.getRecent(); 76 std::vector<QString> recent = m_recentFiles.getRecent();
77 if (n >= 0 && n < int(recent.size())) { 77 if (n >= 0 && n < int(recent.size())) {
78 if (open(recent[n], ReplaceMainModel) != FileOpenSucceeded) { 78 if (open(recent[n], ReplaceMainModel) != FileOpenSucceeded) {
79 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \"" 79 std::cerr << "MainWindow::handleOSCMessage: File open failed for path \""
80 << recent[n].toStdString() << "\"" << std::endl; 80 << recent[n] << "\"" << std::endl;
81 } 81 }
82 } 82 }
83 83
84 } else if (message.getMethod() == "save") { 84 } else if (message.getMethod() == "save") {
85 85
86 QString path; 86 QString path;
87 if (message.getArgCount() == 1 && 87 if (message.getArgCount() == 1 &&
88 message.getArg(0).canConvert(QVariant::String)) { 88 message.getArg(0).canConvert(QVariant::String)) {
89 path = message.getArg(0).toString(); 89 path = message.getArg(0).toString();
90 if (QFileInfo(path).exists()) { 90 if (QFileInfo(path).exists()) {
91 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in save" << std::endl; 91 DEBUG << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in save" << endl;
92 } else { 92 } else {
93 saveSessionFile(path); 93 saveSessionFile(path);
94 } 94 }
95 } 95 }
96 96
100 if (getMainModel()) { 100 if (getMainModel()) {
101 if (message.getArgCount() == 1 && 101 if (message.getArgCount() == 1 &&
102 message.getArg(0).canConvert(QVariant::String)) { 102 message.getArg(0).canConvert(QVariant::String)) {
103 path = message.getArg(0).toString(); 103 path = message.getArg(0).toString();
104 if (QFileInfo(path).exists()) { 104 if (QFileInfo(path).exists()) {
105 std::cerr << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in export" << std::endl; 105 DEBUG << "MainWindow::handleOSCMessage: Refusing to overwrite existing file in export" << endl;
106 } else { 106 } else {
107 WavFileWriter writer(path, 107 WavFileWriter writer(path,
108 getMainModel()->getSampleRate(), 108 getMainModel()->getSampleRate(),
109 getMainModel()->getChannelCount(), 109 getMainModel()->getChannelCount(),
110 WavFileWriter::WriteToTemporary); 110 WavFileWriter::WriteToTemporary);
305 LayerFactory::LayerType type = 305 LayerFactory::LayerType type =
306 LayerFactory::getInstance()->getLayerTypeForName(str); 306 LayerFactory::getInstance()->getLayerTypeForName(str);
307 307
308 if (type == LayerFactory::UnknownLayer) { 308 if (type == LayerFactory::UnknownLayer) {
309 std::cerr << "WARNING: MainWindow::handleOSCMessage: unknown layer " 309 std::cerr << "WARNING: MainWindow::handleOSCMessage: unknown layer "
310 << "type " << str.toStdString() << std::endl; 310 << "type " << str << std::endl;
311 } else { 311 } else {
312 312
313 LayerConfiguration configuration(type, 313 LayerConfiguration configuration(type,
314 getMainModel(), 314 getMainModel(),
315 channel); 315 channel);
429 429
430 deleteCurrentLayer(); 430 deleteCurrentLayer();
431 431
432 } else { 432 } else {
433 433
434 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown delete target " << target.toStdString() << std::endl; 434 std::cerr << "WARNING: MainWindow::handleOSCMessage: Unknown delete target " << target << std::endl;
435 } 435 }
436 } 436 }
437 437
438 } else if (message.getMethod() == "zoom") { 438 } else if (message.getMethod() == "zoom") {
439 439