Skip to content

Commit

Permalink
Update infos when changing a block while beeing on the info page
Browse files Browse the repository at this point in the history
  • Loading branch information
dkratzert committed Sep 28, 2023
1 parent addf535 commit d065ca4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions finalcif/appwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ def open_cod_page(self) -> None:
self.save_current_cif_file()
self.load_cif_file(self.cif.finalcif_file, self.current_block, load_changes=False)
self.deposit.cif = self.cif
self.ui.MainStackedWidget.setCurrentIndex(7)
self.ui.MainStackedWidget.got_to_cod_page()

def event(self, event: QEvent) -> bool:
if event.type() == QEvent.KeyPress:
Expand Down Expand Up @@ -1526,14 +1526,17 @@ def _load_block(self, index: int, load_changes: bool = True) -> None:
self.ui.CheckcifPlaintextEdit.clear()
self.ui.TemplatesStackedWidget.setCurrentIndex(0)
self.authors = AuthorLoops(ui=self.ui, cif=self.cif, app=self)
if not self.ui.MainStackedWidget.on_checkcif_page():
if not (self.ui.MainStackedWidget.on_checkcif_page() or self.ui.MainStackedWidget.on_info_page()):
self.ui.MainStackedWidget.got_to_main_page()
self.deposit.cif = self.cif
# self.ui.cif_main_table.resizeRowsToContents()
self.ui.cif_main_table.vheaderitems.clear()
for row_number in range(self.ui.cif_main_table.model().rowCount()):
vhead_key = self.get_key_by_row_number(row_number)
self.ui.cif_main_table.vheaderitems.insert(row_number, vhead_key)
if self.ui.MainStackedWidget.on_info_page():
self.show_residuals()
self.redraw_molecule()

def changes_cif_has_values(self) -> bool:
try:
Expand Down
2 changes: 1 addition & 1 deletion finalcif/displaymol/molecule2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def paintEvent(self, event):
self.painter.setFont(font)
try:
self.draw()
except ValueError as e:
except (ValueError, IndexError) as e:
print(f'Draw structure crashed: {e}')
self.painter.end()

Expand Down
5 changes: 4 additions & 1 deletion finalcif/gui/mainstackwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ def current_page(self):
return self.currentIndex()

def on_checkcif_page(self):
return self.current_page == 6
return self.current_page == 6

def on_info_page(self):
return self.current_page == 2
2 changes: 1 addition & 1 deletion tests/test_author_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def setUp(self) -> None:
self.authorexport_file = Path('tests/examples/testexport_author.cif').resolve()
self.testimport_author = Path('tests/other_templates/AATest_Author.cif').resolve()
self.app = AppWindow(self.testcif)
self.app.show()
#self.app.show()
self.author = {'address': 'address', 'footnote': 'footnote', 'email': 'email',
'name' : 'name', 'orcid': 'orcid', 'phone': 'phone', 'contact': True}
self.app.ui.authorEditTabWidget.setCurrentIndex(0)
Expand Down

0 comments on commit d065ca4

Please sign in to comment.