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

Method readWindowPreferences

src/csvwindow.cpp:660–684  ·  view source on GitHub ↗

Reads the file preferences for the opened file and set the window properties accordingly. */

Source from the content-addressed store, hash-verified

658 Reads the file preferences for the opened file and set the window properties accordingly.
659 */
660void CsvWindow::readWindowPreferences() {
661 nlohmann::json winJson;
662 std::string pathHashStr = std::to_string( std::hash<std::string>{}(getPath()) );
663 std::string filePref = app.getPreference(&file_preferences, pathHashStr, "");
664 if( filePref != "" ) {
665 try {
666 winJson = nlohmann::json::parse( filePref );
667 // set column widths
668 int c = 0;
669 for(const auto &w : winJson["col-widths"] ) {
670 if( c < table->getNumberCols() ) {
671 grid->col_width(c, w);
672 }
673 ++c;
674 }
675 // show or hide headers if needed
676 if( winJson["header-set"].get<bool>() != table->customHeaderRowShown() ) {
677 app.switchHeaderRowCB(NULL,NULL);
678 }
679 } catch(const std::exception& e) {
680 std::cerr << "Error reading file preferences." << std::endl;
681 std::cerr << e.what() << std::endl;
682 }
683 }
684}
685
686
687void CsvWindow::setTypeButton(CsvDefinition definition) {

Callers 1

openFileMethod · 0.80

Calls 7

to_stringFunction · 0.85
parseFunction · 0.85
getPreferenceMethod · 0.80
getNumberColsMethod · 0.80
customHeaderRowShownMethod · 0.80
switchHeaderRowCBMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected