comparison main/main.cpp @ 197:c08c312b2399

* Make RemoteFile far more pervasive, and use it for local files as well so that we can handle both transparently. Make it shallow copy with reference counting, so it can be used by value without having to worry about the cache file lifetime. Use RemoteFile for MainWindow file-open functions, etc
author Chris Cannam
date Thu, 18 Oct 2007 15:31:20 +0000
parents 77cd75905998
children 1871581e4da9
comparison
equal deleted inserted replaced
196:29c356da4ae4 197:c08c312b2399
298 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed; 298 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed;
299 299
300 if (i == args.begin()) continue; 300 if (i == args.begin()) continue;
301 if (i->startsWith('-')) continue; 301 if (i->startsWith('-')) continue;
302 302
303 if (i->startsWith("http:") || i->startsWith("ftp:")) {
304 std::cerr << "opening URL: \"" << i->toStdString() << "\"..." << std::endl;
305 status = gui.openURL(*i);
306 continue;
307 }
308
309 QString path = *i; 303 QString path = *i;
310 304
311 if (path.endsWith("sv")) { 305 if (path.endsWith("sv")) {
312 if (!haveSession) { 306 if (!haveSession) {
313 status = gui.openSessionFile(path); 307 status = gui.openSession(path);
314 if (status == MainWindow::FileOpenSucceeded) { 308 if (status == MainWindow::FileOpenSucceeded) {
315 haveSession = true; 309 haveSession = true;
316 haveMainModel = true; 310 haveMainModel = true;
317 } 311 }
318 } else { 312 } else {
320 status = MainWindow::FileOpenSucceeded; 314 status = MainWindow::FileOpenSucceeded;
321 } 315 }
322 } 316 }
323 if (status != MainWindow::FileOpenSucceeded) { 317 if (status != MainWindow::FileOpenSucceeded) {
324 if (!haveMainModel) { 318 if (!haveMainModel) {
325 status = gui.openSomeFile(path, MainWindow::ReplaceMainModel); 319 status = gui.open(path, MainWindow::ReplaceMainModel);
326 if (status == MainWindow::FileOpenSucceeded) { 320 if (status == MainWindow::FileOpenSucceeded) {
327 haveMainModel = true; 321 haveMainModel = true;
328 } 322 }
329 } else { 323 } else {
330 if (haveSession && !havePriorCommandLineModel) { 324 if (haveSession && !havePriorCommandLineModel) {
331 status = gui.openSomeFile(path, MainWindow::AskUser); 325 status = gui.open(path, MainWindow::AskUser);
332 if (status == MainWindow::FileOpenSucceeded) { 326 if (status == MainWindow::FileOpenSucceeded) {
333 havePriorCommandLineModel = true; 327 havePriorCommandLineModel = true;
334 } 328 }
335 } else { 329 } else {
336 status = gui.openSomeFile(path, MainWindow::CreateAdditionalModel); 330 status = gui.open(path, MainWindow::CreateAdditionalModel);
337 } 331 }
338 } 332 }
339 } 333 }
340 if (status == MainWindow::FileOpenFailed) { 334 if (status == MainWindow::FileOpenFailed) {
341 QMessageBox::critical 335 QMessageBox::critical
342 (&gui, QMessageBox::tr("Failed to open file"), 336 (&gui, QMessageBox::tr("Failed to open file"),
343 QMessageBox::tr("File \"%1\" could not be opened").arg(path)); 337 QMessageBox::tr("File or URL \"%1\" could not be opened").arg(path));
344 } 338 }
345 } 339 }
346 340
347 341
348 342