Reads the file preferences for the opened file and set the window properties accordingly. */
| 658 | Reads the file preferences for the opened file and set the window properties accordingly. |
| 659 | */ |
| 660 | void 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 | |
| 687 | void CsvWindow::setTypeButton(CsvDefinition definition) { |
no test coverage detected