def startSearch(self): input = self.searchArea.searchLine.text() db = thread.load() songList = [] songGenerator = (Song(self.tree.comm, **dict) for dict in db) self.tree.model().removeRows(0, self.tree.model().rowCount()) if self.searchArea.searchExact.isChecked(): songList = [e for e in songGenerator if e.exactMatch(input)] elif self.searchArea.searchPrecise.isChecked(): songList = [e for e in songGenerator if e.preciseMatch(input)] else: songList = [e for e in songGenerator if e.fuzzyMatch(input)] del db[:] songList.sort(key=self.tree.sortFunc) self.tree.populateTree(songList)
def startSearch(self): input = self.searchArea.searchLine.text() db = thread.load() songList = [] songGenerator = (Song(self.tree.comm, **dict) for dict in db) self.tree.model().removeRows(0, self.tree.model().rowCount()) if self.searchArea.searchExact.isChecked(): songList = [ e for e in songGenerator if e.exactMatch(input) ] elif self.searchArea.searchPrecise.isChecked(): songList = [ e for e in songGenerator if e.preciseMatch(input) ] else: songList = [ e for e in songGenerator if e.fuzzyMatch(input) ] del db[:] songList.sort(key=self.tree.sortFunc) self.tree.populateTree(songList)
def initUI(self): self.setModel(QStandardItemModel()) self.setContextMenuPolicy(Qt.CustomContextMenu) self.setUniformRowHeights(True) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.setSelectionBehavior(QAbstractItemView.SelectRows) self.setHeaderHidden(True) db = thread.load() songList = [Song(self.comm, **dict) for dict in db] songList.sort(key=self.sortFunc) #start1 = time.perf_counter() self.populateTree(songList) #start2 = time.perf_counter() #print('time', start2-start1) # Exand the root node self.expand(self.indexAt(QtCore.QPoint(0, 0))) self.show()
def initUI(self): self.setModel(QStandardItemModel()) self.setContextMenuPolicy(Qt.CustomContextMenu) self.setUniformRowHeights(True) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.setSelectionBehavior(QAbstractItemView.SelectRows) self.setHeaderHidden(True) db = thread.load() songList = [Song(self.comm, **dict) for dict in db] songList.sort(key=self.sortFunc) #start1 = time.perf_counter() self.populateTree(songList) #start2 = time.perf_counter() #print('time', start2-start1) # Exand the root node self.expand(self.indexAt(QtCore.QPoint(0,0))) self.show()