-
Notifications
You must be signed in to change notification settings - Fork 0
/
PCEModels.py
72 lines (67 loc) · 2.05 KB
/
PCEModels.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# Copyright (C) 2014 Chaserhkj
# This file is licensed under the MIT license
# For more details, see COPYRIGHT
from PyQt5.QtCore import QAbstractListModel
from PyQt5.QtCore import QVariant
from PyQt5.QtCore import Qt
class EmojiModel(QAbstractListModel):
def __init__(self, emojis):
self._emojis = [(i["description"], i["emoticon"]) for i in emojis]
super(EmojiModel,self).__init__()
def rowCount(self, index = None):
return len(self._emojis)
def data(self, index, role = 0):
if role >= 0 and role < 2:
return self._emojis[index.row()][role]
else:
return QVariant()
def setEmojis(self, emojis):
self.beginResetModel()
self._emojis = [(i["description"], i["emoticon"]) for i in emojis]
self.endResetModel()
def roleNames(self):
return {
0:"name",
1:"content"
}
class CateModel(QAbstractListModel):
def __init__(self, cates):
self._cates = cates
super(CateModel,self).__init__()
def rowCount(self, index = None):
return len(self._cates)
def data(self, index, role = 0):
if role == 0:
return self._cates[index.row()]
else:
return QVariant()
def setCates(self, cates):
self.beginResetModel()
self._cates = cates
self.endResetModel()
def roleNames(self):
return {
0:"name",
1:"content"
}
class RepoModel(QAbstractListModel):
def __init__(self, repos):
self._repos = repos
super(RepoModel,self).__init__()
def rowCount(self, index = None):
return len(self._repos)
def data(self, index, role = 0):
if role >= 0 and role < 2:
return self._repos[index.row()][role]
else:
return QVariant()
def setRepos(self, repos):
self.beginResetModel()
self._repos = repos
self.endResetModel()
def roleNames(self):
return {
0:"name",
1:"content"
}