Live update progress in table

This commit is contained in:
BasioMeusPuga
2017-11-29 03:38:06 +05:30
parent c72eff22c7
commit 46e6991bc1
3 changed files with 26 additions and 3 deletions

View File

@@ -325,9 +325,12 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
def set_toc_position(self, event=None):
current_tab = self.tabWidget.widget(self.tabWidget.currentIndex())
# We're updating the underlying model to have real-time
# We're updating the underlying models to have real-time
# updates on the read status
# Since there are 2 separate models, they will each have to
# be updated individually
# The listView model
# Set a baseline model index in case the item gets deleted
# E.g It's open in a tab and deleted from the library
model_index = None
@@ -349,6 +352,21 @@ class MainUI(QtWidgets.QMainWindow, mainwindow.Ui_MainWindow):
self.lib_ref.view_model.setData(
model_index, current_tab.metadata['position'], QtCore.Qt.UserRole + 7)
# The tableView model
model_index = None
start_index = self.lib_ref.table_model.index(0, 0)
matching_item = self.lib_ref.table_model.match(
start_index,
QtCore.Qt.UserRole + 1,
current_tab.metadata['hash'],
1, QtCore.Qt.MatchExactly)
if matching_item:
model_row = matching_item[0].row()
self.lib_ref.table_model.display_data[model_row][5][
'position'] = current_tab.metadata['position']
# Go on to change the value of the Table of Contents box
current_tab.change_chapter_tocBox()
def set_fullscreen(self):

View File

@@ -129,7 +129,7 @@ class Library:
# all_metadata is just being sent. It is not being displayed
# It will be correlated to the current row as its first userrole
self.table_rows.append(
(title, author, None, year, tags, all_metadata))
[title, author, None, year, tags, all_metadata, i[8]])
def create_table_model(self):
table_header = ['Title', 'Author', 'Status', 'Year', 'Tags']

View File

@@ -58,7 +58,7 @@ class LibraryTableModel(QtCore.QAbstractTableModel):
return return_pixmap
if role == QtCore.Qt.DisplayRole:
elif role == QtCore.Qt.DisplayRole:
value = self.display_data[index.row()][index.column()]
return value
@@ -66,6 +66,11 @@ class LibraryTableModel(QtCore.QAbstractTableModel):
# The rest of the roles can be accomodated here.
value = self.display_data[index.row()][5]
return value
elif role == QtCore.Qt.UserRole + 1:
value = self.display_data[index.row()][6]
return value
else:
return QtCore.QVariant()