Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong0618 committed Feb 20, 2023
1 parent 633d28f commit 39ef0c8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions kindle_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self):
# self.setup_logger()
self.book_model = BookItemModel(self.ui.bookView, [], ["序号", "书名", "作者"])
self.ui.bookView.setModel(self.book_model)
#self.ui.bookView.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) #allow selection so user can choose items to download
# self.ui.bookView.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) #allow selection so user can choose items to download
self.ui.bookView.horizontalHeader().setSectionResizeMode(
1, QtWidgets.QHeaderView.Stretch
)
Expand Down Expand Up @@ -220,7 +220,9 @@ def on_download_books(self):
self.download_books("all")

def on_download_selected_books(self):
self.book_model.mark_selected(self.ui.bookView.selectionModel().selectedRows(column=0))
self.book_model.mark_selected(
self.ui.bookView.selectionModel().selectedRows(column=0)
)
self.download_books("selected")

def on_finish_download(self):
Expand Down Expand Up @@ -258,7 +260,7 @@ def mark_done(self, idx):
def mark_selected(self, rows):
for index in rows:
idx = self.data(index, QtCore.Qt.DisplayRole)
self._data[idx-1] = self._data[idx-1]._replace(selected=True)
self._data[idx - 1] = self._data[idx - 1]._replace(selected=True)
self.layoutAboutToBeChanged.emit()
self.dataChanged.emit(
self.createIndex(idx, 0), self.createIndex(idx, self.columnCount(0))
Expand Down

0 comments on commit 39ef0c8

Please sign in to comment.