* Switch header row: Default Headers (A,B,..) to Custom Headers (First Row in Data) * Returns 1 if header is activated, 0 if not */
| 622 | * Returns 1 if header is activated, 0 if not |
| 623 | */ |
| 624 | int CsvTable::switchHeader() { |
| 625 | int ret; |
| 626 | |
| 627 | if( storage.rows() <= 1 && hasCustomHeaderRow == false) { |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | if( hasCustomHeaderRow ) { |
| 632 | // Custom Headers => Default Headers |
| 633 | std::vector< std::string > newRow(storage.columns()); |
| 634 | for( table_index_t c = 0; c < (table_index_t) newRow.size(); ++c ) { |
| 635 | newRow.at(c) = getHeaderCell(c); |
| 636 | } |
| 637 | storage.push_front(newRow); |
| 638 | for( table_index_t c = 0; c < (table_index_t) headerRow->size(); ++c ) { |
| 639 | headerRow->at(c) = ""; |
| 640 | } |
| 641 | hasCustomHeaderRow = false; |
| 642 | moveFlags(0, 1); |
| 643 | ret = 0; |
| 644 | } else { |
| 645 | // Default Headers => Custom Headers |
| 646 | for( table_index_t c = 0; c < getNumberCols(); ++c ) { |
| 647 | headerRow->at(c) = getCell(0,c); |
| 648 | } |
| 649 | storage.deleteRows(0,0); |
| 650 | hasCustomHeaderRow = true; |
| 651 | moveFlags(0, -1); |
| 652 | ret = 1; |
| 653 | } |
| 654 | updateInternals(); |
| 655 | return ret; |
| 656 | } |
| 657 | |
| 658 | bool CsvTable::customHeaderRowShown() { |
| 659 | return hasCustomHeaderRow; |
no test coverage detected