Stores file preferences for this file in preferences file Creates a JSON */
| 635 | Creates a JSON |
| 636 | */ |
| 637 | void 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 | /* |
no test coverage detected