@@ -313,20 +313,21 @@ def edit_title(self, row):
313313
314314 def delete_title (self , row ):
315315 # print(f"Deleting row {row}")
316- if row < 0 or row >= self . modelTitles . rowCount () :
316+ if not row :
317317 return
318- index = self .modelTitles .index (row , 0 )
318+ proxy_index = QtCore .QModelIndex (row )
319+ source_index = self .proxy_modelTitles .mapToSource (proxy_index )
320+ row_data = self .modelTitles .data (source_index , QtCore .Qt .ItemDataRole .UserRole )
319321 reply = QtWidgets .QMessageBox .question (
320322 self , 'Delete Title' ,
321- f' Are you sure you want to delete this title?' ,
323+ f" Are you sure you want to delete this title?\n { row_data [ 0 ] } — { row_data [ 1 ] } " ,
322324 QtWidgets .QMessageBox .StandardButton .Yes | QtWidgets .QMessageBox .StandardButton .No
323325 )
324326 if reply == QtWidgets .QMessageBox .StandardButton .Yes :
325327 # Delete logic here
326- row_data = index .data (QtCore .Qt .ItemDataRole .UserRole )
327328 if not row_data :
328329 return
329- result = app .DeleteTitle (DB , row_data )
330+ result = app .DeleteTitle (DB , row_data [ 0 ] )
330331 dlg = QtWidgets .QMessageBox (self )
331332 dlg .setWindowTitle ('Deleting Title' )
332333 if (result ['success' ]):
@@ -359,17 +360,18 @@ def edit_update(self, row):
359360
360361 def delete_update (self , row ):
361362 # print(f"Deleting row {row}")
362- if row < 0 or row >= self . modelUpdates . rowCount () :
363+ if not row :
363364 return
364- index = self .modelUpdates .index (row , 0 )
365+ proxy_index = QtCore .QModelIndex (row )
366+ source_index = self .proxy_modelUpdates .mapToSource (proxy_index )
367+ row_data = self .modelUpdates .data (source_index , QtCore .Qt .ItemDataRole .UserRole )
365368 reply = QtWidgets .QMessageBox .question (
366369 self , 'Delete Update' ,
367- ' Are you sure you want to delete this update?' ,
370+ f" Are you sure you want to delete this update?\n Title: { row_data [ 1 ] } - { row_data [ 2 ] } \n Update: { row_data [ 0 ] } - { row_data [ 3 ] } " ,
368371 QtWidgets .QMessageBox .StandardButton .Yes | QtWidgets .QMessageBox .StandardButton .No
369372 )
370373 if reply == QtWidgets .QMessageBox .StandardButton .Yes :
371374 # Delete logic here
372- row_data = index .data (QtCore .Qt .ItemDataRole .UserRole )
373375 if not row_data :
374376 return
375377 result = app .DeleteUpdate (DB , row_data [0 ])
0 commit comments