Class SliceListModel<T extends GObject>
- All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>, SequencedCollection<T>, ListModel<T>, SectionModel<T>, Proxy, ListModelJavaList<T>
A list model that presents a slice of another model.
This is useful when implementing paging by setting the size to the number of elements per page and updating the offset whenever a different page is opened.
GtkSliceListModel passes through sections from the underlying model.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSliceListModel.Builder<B extends SliceListModel.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classSliceListModel.SliceListModelClass<T extends GObject>Nested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface ListModel
ListModel.ItemsChangedCallback, ListModel.ListModel$Impl, ListModel.ListModelInterfaceNested classes/interfaces inherited from interface ListModelJavaList
ListModelJavaList.SubList<E,List> Nested classes/interfaces inherited from interface SectionModel
SectionModel.SectionModel$Impl, SectionModel.SectionModelInterface, SectionModel.SectionsChangedCallback -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new SliceListModel.SliceListModel(MemorySegment address) Create a SliceListModel instance for the provided memory address.SliceListModel(@Nullable ListModel model, int offset, int size) Creates a new slice model. -
Method Summary
Modifier and TypeMethodDescriptionprotected SliceListModelasParent()Return this instance as if it were its parent type.static SliceListModel.Builder<? extends SliceListModel.Builder> builder()ASliceListModel.Builderobject constructs aSliceListModelwith the specified properties.static MemoryLayoutThe memory layout of the native struct.@Nullable ListModelgetModel()Gets the model that is currently being used ornullif none.intGets the offset set via gtk_slice_list_model_set_offset().intgetSize()Gets the size set via gtk_slice_list_model_set_size().static @Nullable TypegetType()Get the GType of the SliceListModel class.voidSets the model to show a slice of.voidsetOffset(int offset) Sets the offset into the original model for this slice.voidsetSize(int size) Sets the maximum size.Methods inherited from class 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, 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, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliteratorMethods inherited from interface ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChangedMethods inherited from interface ListModelJavaList
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArrayMethods inherited from interface SectionModel
emitSectionsChanged, getSection, onSectionsChanged, sectionsChanged
-
Constructor Details
-
SliceListModel
Create a SliceListModel instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
SliceListModel
Creates a new slice model.
It presents the slice from
offsetto offset +sizeof the givenmodel.- Parameters:
model- The model to useoffset- the offset of the slicesize- maximum size of the slice
-
SliceListModel
public SliceListModel()Create a new SliceListModel.
-
-
Method Details
-
getType
Get the GType of the SliceListModel class.- Returns:
- the GType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
getModel
Gets the model that is currently being used ornullif none.- Returns:
- The model in use
-
getOffset
public int getOffset()Gets the offset set via gtk_slice_list_model_set_offset().- Returns:
- The offset
-
getSize
public int getSize()Gets the size set via gtk_slice_list_model_set_size().- Returns:
- The size
-
setModel
Sets the model to show a slice of.
The model's item type must conform to
self'sitem type.- Parameters:
model- The model to be sliced
-
setOffset
public void setOffset(int offset) Sets the offset into the original model for this slice.
If the offset is too large for the sliced model, this SliceListModel will end up empty.
- Parameters:
offset- the new offset to use
-
setSize
public void setSize(int size) Sets the maximum size. this SliceListModel will never have more items than
size.It can however have fewer items if the offset is too large or the model sliced from doesn't have enough items.
- Parameters:
size- the maximum size
-
builder
ASliceListModel.Builderobject constructs aSliceListModelwith the specified properties. Use the variousset...()methods to set properties, and finish construction withSliceListModel.Builder.build().- Returns:
- the builder object
-