Added clear method to PaneModel

This commit is contained in:
Christian Muehlhaeuser 2019-05-15 05:01:47 +02:00
parent e81b8db602
commit f0f3f491c8
No known key found for this signature in database
GPG key ID: 3CF9FA45CA1EBB7E

View file

@ -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 {