Class FilterListModel<T extends GObject>
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,List<T>
,SequencedCollection<T>
,ListModel<T>
,SectionModel<T>
,Proxy
,ListModelJavaList<T>
It hides some elements from the underlying model according to
criteria given by a GtkFilter
.
The model can be set up to do incremental filtering, so that
filtering long lists doesn't block the UI. See
setIncremental(boolean)
for details.
GtkFilterListModel
passes through sections from the underlying model.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
FilterListModel.Builder<B extends FilterListModel.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
FilterListModel.FilterListModelClass<T extends GObject>
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModel$Impl, ListModel.ListModelInterface
Nested classes/interfaces inherited from interface org.javagi.gio.ListModelJavaList
ListModelJavaList.SubList<E extends GObject,
List extends ListModelJavaList<E>> Nested classes/interfaces inherited from interface org.gnome.gtk.SectionModel
SectionModel.SectionModel$Impl, SectionModel.SectionModelInterface, SectionModel.SectionsChangedCallback
-
Field Summary
Fields inherited from class org.javagi.base.ProxyInstance
address
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new FilterListModel.FilterListModel
(MemorySegment address) Create a FilterListModel proxy instance for the provided memory address.FilterListModel
(@Nullable ListModel model, @Nullable Filter filter) Creates a newGtkFilterListModel
that will filtermodel
using the givenfilter
. -
Method Summary
Modifier and TypeMethodDescriptionprotected FilterListModel
asParent()
Returns this instance as if it were its parent type.static FilterListModel.Builder
<? extends FilterListModel.Builder> builder()
AFilterListModel.Builder
object constructs aFilterListModel
with the specified properties.Gets theGtkFilter
currently set on this FilterListModel.boolean
Returns whether incremental filtering is enabled.getModel()
Gets the model currently filtered ornull
if none.int
Returns the number of items that have not been filtered yet.static Type
getType()
Get the GType of the FilterListModel classvoid
Sets the filter used to filter items.void
setIncremental
(boolean incremental) Sets the filter model to do an incremental sort.void
Sets the model to be filtered.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
Methods inherited from interface org.gnome.gio.ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChanged
Methods inherited from interface org.javagi.gio.ListModelJavaList
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
Methods inherited from interface org.gnome.gtk.SectionModel
emitSectionsChanged, getSection, onSectionsChanged, sectionsChanged
-
Constructor Details
-
FilterListModel
Create a FilterListModel proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
FilterListModel
-
FilterListModel
public FilterListModel()Creates a new FilterListModel.
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getFilter
Gets theGtkFilter
currently set on this FilterListModel.- Returns:
- The filter currently in use
-
getIncremental
public boolean getIncremental()Returns whether incremental filtering is enabled.- Returns:
true
if incremental filtering is enabled
-
getModel
Gets the model currently filtered ornull
if none.- Returns:
- The model that gets filtered
-
getPending
public int getPending()Returns the number of items that have not been filtered yet.You can use this value to check if this FilterListModel is busy filtering by comparing the return value to 0 or you can compute the percentage of the filter remaining by dividing the return value by the total number of items in the underlying model:
pending = gtk_filter_list_model_get_pending (self); model = gtk_filter_list_model_get_model (self); percentage = pending / (double) g_list_model_get_n_items (model);
If no filter operation is ongoing - in particular when
Gtk.FilterListModel:incremental
isfalse
- this function returns 0.- Returns:
- The number of items not yet filtered
-
setFilter
Sets the filter used to filter items.- Parameters:
filter
- filter to use
-
setIncremental
public void setIncremental(boolean incremental) Sets the filter model to do an incremental sort.When incremental filtering is enabled, the
GtkFilterListModel
will not run filters immediately, but will instead queue an idle handler that incrementally filters the items and adds them to the list. This of course means that items are not instantly added to the list, but only appear incrementally.When your filter blocks the UI while filtering, you might consider turning this on. Depending on your model and filters, this may become interesting around 10,000 to 100,000 items.
By default, incremental filtering is disabled.
See
getPending()
for progress information about an ongoing incremental filtering operation.- Parameters:
incremental
-true
to enable incremental filtering
-
setModel
Sets the model to be filtered.Note that GTK makes no effort to ensure that
model
conforms to the item type of this FilterListModel. It assumes that the caller knows what they are doing and have set up an appropriate filter to ensure that item types match.- Parameters:
model
- The model to be filtered
-
builder
AFilterListModel.Builder
object constructs aFilterListModel
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withFilterListModel.Builder.build()
.
-