if self sortOrder Qt AscendingOrder lo hi self ui resultsList topLevel

 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
if self.sortOrder == Qt.AscendingOrder:
lo = 0
hi = self.ui.resultsList.topLevelItemCount()
if hi != 0 and not self.ui.resultsList.topLevelItem(0).__lt__(result):
hi = 0
while (True):
mid = (hi + lo)/2
if mid == lo:
break
if self.ui.resultsList.topLevelItem(mid).__lt__(result):
lo = mid
else:
hi = mid
self.ui.resultsList.insertTopLevelItem(hi, result)
else:
cnt = self.ui.resultsList.topLevelItemCount()
lo = 0
hi = cnt
if hi != 0 and not self.ui.resultsList.topLevelItem(cnt - 1).__lt__(result):
hi = 0
while True:
mid = (hi + lo)/2
if mid == lo:
break
if self.ui.resultsList.topLevelItem(cnt - 1 - mid).__lt__(result):
lo = mid
else:
hi = mid
self.ui.resultsList.insertTopLevelItem(cnt - hi, result)