Added ReloadListViewItem method to ListView interface

This commit is contained in:
Alexei Anoshenko 2026-08-28 18:54:47 +03:00
parent 9b9adcab88
commit 655bea09a8
2 changed files with 38 additions and 3 deletions

View File

@ -3,9 +3,10 @@
* Removed "style-disabled" property and GetDisabledStyle function * Removed "style-disabled" property and GetDisabledStyle function
* Added GoogleFonts field to AppParams * Added GoogleFonts field to AppParams
* Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded, GetBackgroundColorPair, * Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded, GetBackgroundColorPair,
GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair, ReloadListViewItem
* Added ClientSession interface * Added ClientSession interface
* Added ClientSession, Popups, PopupDefault, PopupDefaultsSeq, and SetPopupDefaults methods to Session interface * Added ClientSession, Popups, PopupDefault, PopupDefaultsSeq, and SetPopupDefaults methods to Session interface
* Added ReloadListViewItem method to ListView interface
* Removed ClientItem, SetClientItem, RemoveClientItem, and RemoveAllClientItems methods from Session interface * Removed ClientItem, SetClientItem, RemoveClientItem, and RemoveAllClientItems methods from Session interface
* Added DismissWithoutAnimation add SetHotKey methods to Popup interface * Added DismissWithoutAnimation add SetHotKey methods to Popup interface
* Added "outside-color" add "outside-filter" properties to Popup interface * Added "outside-color" add "outside-filter" properties to Popup interface

View File

@ -121,9 +121,13 @@ const (
type ListView interface { type ListView interface {
View View
ParentView ParentView
// ReloadListViewData updates ListView content // ReloadListViewData updates ListView content
ReloadListViewData() ReloadListViewData()
// ReloadListViewItem updates the contents of the item at the given index.
ReloadListViewItem(index int)
getItemFrames() []Frame getItemFrames() []Frame
} }
@ -445,9 +449,8 @@ func (listView *listViewData) getAdapter() ListAdapter {
} }
func (listView *listViewData) ReloadListViewData() { func (listView *listViewData) ReloadListViewData() {
itemCount := 0
if adapter := listView.getAdapter(); adapter != nil { if adapter := listView.getAdapter(); adapter != nil {
itemCount = adapter.ListSize() itemCount := adapter.ListSize()
if itemCount != len(listView.items) { if itemCount != len(listView.items) {
listView.items = make([]View, itemCount) listView.items = make([]View, itemCount)
@ -465,6 +468,25 @@ func (listView *listViewData) ReloadListViewData() {
updateInnerHTML(listView.htmlID(), listView.session) updateInnerHTML(listView.htmlID(), listView.session)
} }
func (listView *listViewData) ReloadListViewItem(index int) {
adapter := listView.getAdapter()
if adapter == nil || index < 0 || index >= adapter.ListSize() || index >= len(listView.items) {
return
}
listView.items[index] = adapter.ListItem(index, listView.Session())
if view := listView.items[index]; view != nil {
html := allocStringBuilder()
defer freeStringBuilder(html)
listView.session.callFunc("hideTooltip")
viewHTML(view, html, "")
listView.session.updateInnerHTML(listView.htmlID()+"-"+strconv.Itoa(index), html.String())
}
}
func (listView *listViewData) getItemFrames() []Frame { func (listView *listViewData) getItemFrames() []Frame {
return listView.itemFrame return listView.itemFrame
} }
@ -1281,6 +1303,7 @@ func GetListViewAdapter(view View, subviewID ...string) ListAdapter {
} }
// ReloadListViewData updates ListView content // ReloadListViewData updates ListView content
//
// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated. // If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated.
func ReloadListViewData(view View, subviewID ...string) { func ReloadListViewData(view View, subviewID ...string) {
if view = getSubview(view, subviewID); view != nil { if view = getSubview(view, subviewID); view != nil {
@ -1289,3 +1312,14 @@ func ReloadListViewData(view View, subviewID ...string) {
} }
} }
} }
// ReloadListViewItem updates updates the contents of the ListView item at the given index.
//
// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated.
func ReloadListViewItem(index int, view View, subviewID ...string) {
if view = getSubview(view, subviewID); view != nil {
if listView, ok := view.(ListView); ok {
listView.ReloadListViewItem(index)
}
}
}