package main import ( "github.com/therecipe/qt/core" ) // Model Roles const ( PaneName = int(core.Qt__UserRole) + 1<= len(m.Panes()) { return core.NewQVariant() } var p = m.Panes()[index.Row()] switch role { case PaneName: { return core.NewQVariant1(p.Name) } case PaneSticky: { return core.NewQVariant1(p.Sticky) } case MsgModel: { return p.Model.ToVariant() } default: { return core.NewQVariant() } } } func (m *PaneModel) rowCount(parent *core.QModelIndex) int { return len(m.Panes()) } func (m *PaneModel) columnCount(parent *core.QModelIndex) int { return 1 } 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 { m.BeginInsertRows(core.NewQModelIndex(), 0, 0) m.SetPanes(append(m.Panes(), p)) } else { m.BeginInsertRows(core.NewQModelIndex(), len(m.Panes())-1, len(m.Panes())-1) m.SetPanes(append(m.Panes()[:len(m.Panes())-1], p, m.Panes()[len(m.Panes())-1])) } m.EndInsertRows() } func (m *PaneModel) removePane(row int) { m.BeginRemoveRows(core.NewQModelIndex(), row, row) m.SetPanes(append(m.Panes()[:row], m.Panes()[row+1:]...)) m.EndRemoveRows() } func init() { PaneModel_QRegisterMetaType() Pane_QRegisterMetaType() }