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

Method storeWindowPreferences

src/csvwindow.cpp:637–654  ·  view source on GitHub ↗

Stores file preferences for this file in preferences file Creates a JSON */

Source from the content-addressed store, hash-verified

635 Creates a JSON
636 */
637void CsvWindow::storeWindowPreferences() {
638 nlohmann::json winJson; // stores the preferences for this single window / file
639 // get column widths
640 std::vector<int> colWidths;
641 for(table_index_t c = 0; c < table->getNumberCols(); ++c ) {
642 colWidths.push_back( grid->col_width(c) );
643 }
644 // create JSON
645 winJson["path"] = getPath();
646 winJson["timestamp"] = std::to_string( Helper::getTimestamp() );
647 winJson["header-set"] = table->customHeaderRowShown();
648 winJson["col-widths"] = colWidths;
649 // create hash for the file path
650 std::size_t pathHash = std::hash<std::string>{}(winJson["path"]);
651 std::string pathHashStr = std::to_string(pathHash);
652 // store preferences
653 file_preferences.set(pathHashStr.c_str(), winJson.dump().c_str());
654}
655
656
657/*

Callers 2

saveFileMethod · 0.80
closeWindowMethod · 0.80

Calls 6

to_stringFunction · 0.85
getNumberColsMethod · 0.80
push_backMethod · 0.80
customHeaderRowShownMethod · 0.80
setMethod · 0.80
dumpMethod · 0.45

Tested by

no test coverage detected