From f0f3f491c857b770d3f80c4ac508b8ba73743360 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 15 May 2019 05:01:47 +0200 Subject: [PATCH] Added clear method to PaneModel --- panemodel.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/panemodel.go b/panemodel.go index e60ba96..fef1c36 100644 --- a/panemodel.go +++ b/panemodel.go @@ -22,6 +22,7 @@ type PaneModel struct { _ func(*Pane) `slot:"addPane"` _ func(row int) `slot:"removePane"` + _ func() `slot:"clear"` } // Pane represents a single pane @@ -48,6 +49,7 @@ func (m *PaneModel) init() { m.ConnectAddPane(m.addPane) m.ConnectRemovePane(m.removePane) + m.ConnectClear(m.clear) } func (m *PaneModel) setData(index *core.QModelIndex, value *core.QVariant, role int) bool { @@ -103,6 +105,12 @@ func (m *PaneModel) roleNames() map[int]*core.QByteArray { return m.Roles() } +func (m *PaneModel) clear() { + m.BeginResetModel() + m.SetPanes([]*Pane{}) + m.EndResetModel() +} + func (m *PaneModel) addPane(p *Pane) { // add pane before the last pane, which is always the notifications pane if len(m.Panes()) == 0 {