@@ -14,22 +14,22 @@ class FileListModel(QAbstractListModel):
1414 def __init__ (self , batch_size = 50 , parent = None ):
1515 super ().__init__ (parent )
1616
17- self .fileList = []
18- self .fileCount = 0
17+ self .total_file_list = []
18+ self .current_file_count = 0
1919 self .batch_size = batch_size
2020
2121 def rowCount (self , parent : QModelIndex = None ) -> int :
22- return self .fileCount
22+ return self .current_file_count
2323
2424 def data (self , index : QModelIndex , role = Qt .DisplayRole ) -> QVariant :
2525 if not index .isValid ():
2626 return QVariant ()
2727
28- if index .row () >= len (self .fileList ) or index .row () < 0 :
28+ if index .row () >= len (self .total_file_list ) or index .row () < 0 :
2929 return QVariant ()
3030
3131 if role == Qt .DisplayRole or role == Qt .ToolTipRole :
32- return self .fileList [index .row ()]
32+ return self .total_file_list [index .row ()]
3333
3434 # elif role == Qt.BackgroundRole:
3535 # batch = (index.row() // self.batch_size) % 2
@@ -41,29 +41,29 @@ def data(self, index: QModelIndex, role=Qt.DisplayRole) -> QVariant:
4141 return QVariant ()
4242
4343 def canFetchMore (self , parent : QModelIndex = None ) -> bool :
44- return self .fileCount < len (self .fileList )
44+ return self .current_file_count < len (self .total_file_list )
4545
4646 def fetchMore (self , parent : QModelIndex = None ):
47- remainder = len (self .fileList ) - self .fileCount
47+ remainder = len (self .total_file_list ) - self .current_file_count
4848 itemsToFetch = min (self .batch_size , remainder )
4949 if itemsToFetch <= 0 :
5050 return
5151
5252 self .beginInsertRows (
53- QModelIndex (), self .fileCount , self .fileCount + itemsToFetch - 1
53+ QModelIndex (), self .current_file_count , self .current_file_count + itemsToFetch - 1
5454 )
5555
56- self .fileCount += itemsToFetch
56+ self .current_file_count += itemsToFetch
5757
5858 self .endInsertRows ()
5959
6060 self .numberPopulated .emit (itemsToFetch )
6161
62- def set_file_list (self , fileList : list ):
62+ def set_total_file_list (self , fileList : list ):
6363 self .beginResetModel ()
6464
65- self .fileList = fileList
66- self .fileCount = 0
65+ self .total_file_list = fileList
66+ self .current_file_count = 0
6767 self .numberPopulated .emit (0 )
6868
6969 self .endResetModel ()
0 commit comments