MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / openFile

Method openFile

src/csvapplication.cpp:475–513  ·  view source on GitHub ↗

* Asks user for a file and opens it. * askUser Should the user be asked about CSV format? * reopen Should the file be opened in the same window? Caution: Changes are overwritten. */

Source from the content-addressed store, hash-verified

473 * reopen Should the file be opened in the same window? Caution: Changes are overwritten.
474 */
475void CsvApplication::openFile(bool askUser, bool reopen) {
476 int winIndex;
477 std::string fn;
478 Fl_Native_File_Chooser fnfc;
479
480 fnfc.title("Pick a file");
481 fnfc.type(Fl_Native_File_Chooser::BROWSE_FILE);
482 fnfc.filter("CSV Files\t*.{txt,csv,tsv}");
483 fnfc.directory(workDir.c_str());
484
485 if( reopen ) {
486 winIndex = app.getTopWindow();
487 if( winIndex >= 0 ) {
488 fn = windows[winIndex].getPath();
489 windows[winIndex].loadFile(fn, true, true);
490 }
491 } else {
492 nfcIsOpen = true;
493 switch ( fnfc.show() ) {
494 case -1:
495 #ifdef DEBUG
496 printf("ERROR: %s\n", fnfc.errmsg());
497 #endif
498 break; // ERROR
499 case 1:
500 #ifdef DEBUG
501 printf("CANCEL\n");
502 #endif
503 break; // CANCEL
504 default:
505 #ifdef DEBUG
506 printf("PICKED: %s\n", fnfc.filename());
507 #endif
508 fn = fnfc.filename();
509 openFile(fn, askUser);
510 }
511 nfcIsOpen = false;
512 }
513}
514
515
516void CsvApplication::openFile(std::string path, bool askUser) {

Callers 4

MyMenuCallbackMethod · 0.80
openFileCBMethod · 0.80
openRecentFileMethod · 0.80
droppedFileCBMethod · 0.80

Calls 12

checkFunction · 0.85
getTopWindowMethod · 0.80
getPathMethod · 0.80
loadFileMethod · 0.80
isUsedMethod · 0.80
createNewWindowMethod · 0.80
setWorkDirMethod · 0.80
setUsedMethod · 0.80
setWindowSlotUsedMethod · 0.80
readWindowPreferencesMethod · 0.80
arrangeColumnsCBMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected