diff --git a/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.cpp b/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.cpp index b089881bf1..50913691e9 100644 --- a/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.cpp +++ b/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.cpp @@ -409,9 +409,7 @@ void TableHeaderComponent::setSortColumnId (const int columnId, const bool sortF if (ci != 0) ci->propertyFlags |= (sortForwards ? sortedForwards : sortedBackwards); - sortChanged = true; - repaint(); - triggerAsyncUpdate(); + reSortTable(); } } @@ -433,6 +431,13 @@ bool TableHeaderComponent::isSortedForwards() const throw() return true; } +void TableHeaderComponent::reSortTable() +{ + sortChanged = true; + repaint(); + triggerAsyncUpdate(); +} + //============================================================================== const String TableHeaderComponent::toString() const { diff --git a/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.h b/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.h index 74744b7ad4..1d7367f1ab 100644 --- a/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.h +++ b/src/juce_appframework/gui/components/controls/juce_TableHeaderComponent.h @@ -220,7 +220,11 @@ public: /** Changes the column which is the sort column. This can cause an asynchronous callback to the tableSortOrderChanged() method of any registered listeners. - @see getSortColumnId, isSortedForwards + + If this method doesn't actually change the column ID, then no re-sort will take place (you can + call reSortTable() to force a re-sort to happen if you've modified the table's contents). + + @see getSortColumnId, isSortedForwards, reSortTable */ void setSortColumnId (const int columnId, const bool sortForwards); @@ -235,6 +239,16 @@ public: */ bool isSortedForwards() const throw(); + /** Triggers a re-sort of the table according to the current sort-column. + + If you modifiy the table's contents, you can call this to signal that the table needs + to be re-sorted. + + (This doesn't do any sorting synchronously - it just asynchronously sends a call to the + tableSortOrderChanged() method of any listeners). + */ + void reSortTable(); + //============================================================================== /** Returns the total width of all the visible columns in the table. */