-
Notifications
You must be signed in to change notification settings - Fork 1
/
stringlistmodel.py
53 lines (36 loc) · 1.69 KB
/
stringlistmodel.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
from PySide2.QtNetwork import QNetworkReply
from PySide2.QtCore import QAbstractListModel, Qt, QModelIndex
from PySide2.QtGui import QIcon, QColor
from PySide2.QtWidgets import QApplication, QStyle
class StringListModel(QAbstractListModel):
def __init__(self,hyperthoughtimpl,parent=None):
QAbstractListModel.__init__(self, parent)
self.hyperthoughtimpl = hyperthoughtimpl
self.directoryList = []
self.uuidList = []
def getLists(self, folderlist):
if self.directoryList != []:
self.beginRemoveRows(self.index(len(self.directoryList),0), len(self.directoryList),len(self.directoryList))
self.directoryList = []
self.uuidList = []
self.endRemoveRows()
for i in range(len(folderlist)):
self.beginInsertRows(self.index(len(self.directoryList),0), len(self.directoryList),len(self.directoryList))
self.directoryList.append(folderlist[i]["content"]["name"])
self.endInsertRows()
self.uuidList.append(folderlist[i]["content"]["pk"])
def rowCount(self, parent=QModelIndex()):
return len(self.directoryList)
def data(self, index, role):
if role == Qt.DisplayRole:
return self.directoryList[index.row()]#.split("/")[-1]
return None
def setData(self,index, value, role):
if role == Qt.DisplayRole:
if not index.isValid():
return False
return index.row()
def addRow(self, filename):
self.beginInsertRows(self.index(len(self.directoryList),0), len(self.directoryList),len(self.directoryList))
self.directoryList.append(filename)
self.endInsertRows()