File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ Return the jsobject that has the id specified by 'id'.
119119
120120## Collection
121121
122- An item for sorting an filtering a JsonListModel. The Collection itself does not
122+ An item for sorting and filtering a JsonListModel. The Collection itself does not
123123store any data, but rather proxies the data stored inside the source model.
124124
125125### model : JsonListModel
@@ -164,6 +164,15 @@ function should return true for items that should be included; otherwise false.
164164Return the jsobject at the index specified by the number. If Collection is sorted or filtered, then
165165the index here refers to the index in the Collection * not* the JsonListModel.
166166
167+ ### reSort() : function
168+
169+ Trigger sorting the collection again.
170+
171+ ** NOTE** Calling this function is * not* required if data within the model itself has changed
172+ (re-sorting will be conducted automatically in that case). You want to call this function if
173+ external data has been updated, e.g. you sort a model by distance and the current position
174+ of the user has changed.
175+
167176### descendingSort : property bool: false
168177
169178Indicates if the role based sorting is sorted in ascending or descending order.
Original file line number Diff line number Diff line change @@ -115,3 +115,8 @@ QJSValue Collection::at(int row) const
115115 return jsonModel->at (source.row ());
116116}
117117
118+ void Collection::reSort ()
119+ {
120+ sort (0 );
121+ }
122+
Original file line number Diff line number Diff line change @@ -26,6 +26,8 @@ class Collection : public QSortFilterProxyModel
2626
2727 Q_INVOKABLE QJSValue at (int ) const ;
2828
29+ Q_INVOKABLE void reSort ();
30+
2931 inline bool caseSensitiveSort () const
3032 {
3133 return sortCaseSensitivity () == Qt::CaseSensitive;
You can’t perform that action at this time.
0 commit comments