|
|
|
@ -46,6 +46,12 @@ class QEChannelListModel(QAbstractListModel, QtEventListener): |
|
|
|
def rowCount(self, index): |
|
|
|
def rowCount(self, index): |
|
|
|
return len(self.channels) |
|
|
|
return len(self.channels) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# also expose rowCount as a property |
|
|
|
|
|
|
|
countChanged = pyqtSignal() |
|
|
|
|
|
|
|
@pyqtProperty(int, notify=countChanged) |
|
|
|
|
|
|
|
def count(self): |
|
|
|
|
|
|
|
return len(self.channels) |
|
|
|
|
|
|
|
|
|
|
|
def roleNames(self): |
|
|
|
def roleNames(self): |
|
|
|
return self._ROLE_MAP |
|
|
|
return self._ROLE_MAP |
|
|
|
|
|
|
|
|
|
|
|
@ -113,6 +119,8 @@ class QEChannelListModel(QAbstractListModel, QtEventListener): |
|
|
|
self.channels = channels |
|
|
|
self.channels = channels |
|
|
|
self.endInsertRows() |
|
|
|
self.endInsertRows() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.countChanged.emit() |
|
|
|
|
|
|
|
|
|
|
|
def on_channel_updated(self, channel): |
|
|
|
def on_channel_updated(self, channel): |
|
|
|
i = 0 |
|
|
|
i = 0 |
|
|
|
for c in self.channels: |
|
|
|
for c in self.channels: |
|
|
|
@ -141,6 +149,8 @@ class QEChannelListModel(QAbstractListModel, QtEventListener): |
|
|
|
self.beginInsertRows(QModelIndex(), 0, 0) |
|
|
|
self.beginInsertRows(QModelIndex(), 0, 0) |
|
|
|
self.channels.insert(0,item) |
|
|
|
self.channels.insert(0,item) |
|
|
|
self.endInsertRows() |
|
|
|
self.endInsertRows() |
|
|
|
|
|
|
|
self.countChanged.emit() |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
@pyqtSlot(str) |
|
|
|
@pyqtSlot(str) |
|
|
|
def remove_channel(self, cid): |
|
|
|
def remove_channel(self, cid): |
|
|
|
@ -152,5 +162,6 @@ class QEChannelListModel(QAbstractListModel, QtEventListener): |
|
|
|
self.beginRemoveRows(QModelIndex(), i, i) |
|
|
|
self.beginRemoveRows(QModelIndex(), i, i) |
|
|
|
self.channels.remove(channel) |
|
|
|
self.channels.remove(channel) |
|
|
|
self.endRemoveRows() |
|
|
|
self.endRemoveRows() |
|
|
|
|
|
|
|
self.countChanged.emit() |
|
|
|
return |
|
|
|
return |
|
|
|
i = i + 1 |
|
|
|
i = i + 1 |
|
|
|
|