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

Method sort

src/csvapplication.cpp:1855–1950  ·  view source on GitHub ↗

* Sort table by column */

Source from the content-addressed store, hash-verified

1853 * Sort table by column
1854 */
1855void CsvApplication::sort(unsigned int column) {
1856 Fl_Choice *colChoice;
1857 Fl_Choice *orderChoice;
1858 Fl_Choice *typeChoice;
1859 My_Fl_Button *sortButton;
1860 int windowIndex = getTopWindow();
1861 std::tuple<Fl_Widget *, Fl_Widget *, Fl_Widget *> widgets;
1862 int searchType = 1;
1863 if( windows[windowIndex].table->isNumericColumn(column, 1000000) ) {
1864 searchType = 0;
1865 }
1866
1867 Fl_Window *topWin = Fl::first_window();
1868
1869 // sortWin = new My_Fl_Small_Window(640,180);
1870 // sortWin->set_modal();
1871 sortWin->color(ColorThemes::getColor(app.getTheme(), "win_bg"));
1872 sortWin->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text"));
1873 sortWin->label("Sort By");
1874 sortWin->callback(doSortWinCB);
1875
1876 sortWin->begin();
1877 colChoice = new Fl_Choice(90, 30, 120, 25, "Column: ");
1878 if( column >= windows[windowIndex].table->headerRow->size() )
1879 column = 0;
1880 for( size_t c = 0; c < windows[windowIndex].table->headerRow->size(); ++c ) {
1881 colChoice->add(windows[windowIndex].table->getHeaderCell(c,false).c_str());
1882 }
1883 colChoice->value(column);
1884 colChoice->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text"));
1885
1886 orderChoice = new Fl_Choice(280, 30, 120, 25, "Order: ");
1887 orderChoice->add("Ascending");
1888 orderChoice->add("Descending");
1889 orderChoice->value(0);
1890 orderChoice->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text"));
1891
1892 typeChoice = new Fl_Choice(470, 30, 120, 25, "Type: ");
1893 typeChoice->add("Numeric");
1894 typeChoice->add("String");
1895 typeChoice->add("String (ignore case)");
1896 typeChoice->value(searchType);
1897 typeChoice->labelcolor(ColorThemes::getColor(app.getTheme(), "win_text"));
1898
1899 std::get<0>(widgets) = colChoice;
1900 std::get<1>(widgets) = orderChoice;
1901 std::get<2>(widgets) = typeChoice;
1902
1903 struct My_Fl_Button::buttonColorStruct colorsHighlightButton;
1904 colorsHighlightButton.background = ColorThemes::getColor(app.getTheme(), "hightlight_button_bg");
1905 colorsHighlightButton.label = ColorThemes::getColor(app.getTheme(), "hightlight_button_text");
1906 colorsHighlightButton.border = ColorThemes::getColor(app.getTheme(), "hightlight_button_border");
1907 colorsHighlightButton.windowBg = ColorThemes::getColor(app.getTheme(), "win_bg");
1908 colorsHighlightButton.borderWidth = ColorThemes::getColor(app.getTheme(), "highlight_button_border_width");
1909 sortButton = new My_Fl_Button(90,100,100,24, "Sort");
1910 sortButton->colors = colorsHighlightButton;
1911 sortButton->callback(doSortCB, &widgets);
1912

Callers

nothing calls this directly

Calls 13

checkFunction · 0.85
isNumericColumnMethod · 0.80
getThemeMethod · 0.80
getHeaderCellMethod · 0.80
setChangedMethod · 0.80
setUsedMethod · 0.80
addUndoStateTableMethod · 0.80
sortTableMethod · 0.80
beginMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected