* Move columns right or left */
| 235 | * Move columns right or left |
| 236 | */ |
| 237 | void CsvTable::moveCols(table_index_t colFromStart, table_index_t colFromEnd, bool right) { |
| 238 | std::string buffer; |
| 239 | if( colFromStart > colFromEnd ) { |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | // Move columns |
| 244 | storage.moveColumns(colFromStart, colFromEnd, right); |
| 245 | |
| 246 | // Move header row |
| 247 | if( right ) { |
| 248 | if( colFromEnd < storage.columns() - 1 && colFromStart >= 0 ) { |
| 249 | buffer = headerRow->at(colFromEnd + 1); |
| 250 | for( table_index_t c = colFromEnd; c >= colFromStart; --c ) { |
| 251 | headerRow->at(c + 1) = headerRow->at(c); |
| 252 | } |
| 253 | headerRow->at(colFromStart) = buffer; |
| 254 | } |
| 255 | } else { |
| 256 | if( colFromStart > 0 && colFromEnd < storage.columns() ) { |
| 257 | buffer = headerRow->at(colFromStart - 1); |
| 258 | for( table_index_t c = colFromStart; c <= colFromEnd; ++c ) { |
| 259 | headerRow->at(c - 1) = headerRow->at(c); |
| 260 | } |
| 261 | headerRow->at(colFromEnd) = buffer; |
| 262 | } |
| 263 | } |
| 264 | updateInternals(); |
| 265 | } |
| 266 | |
| 267 | |
| 268 | /* |
no test coverage detected