# LeoQtFrame.reloadOutline

def reloadOutline(self, event: LeoKeyEvent = None) -> None:

  """reload-outline: Close the outline and reload it.""" c = self.c

  # Commit any open edits. c.endEditing()

  # Make sure the file has a name. if not c.fileName():

  > c.save()

  if not c.fileName():
    g.es_print('Please name the outline', color='red') return

  # Abort the reload if the user vetos closing this outline. if c.changed:

  > veto = False try:

  > > c.promptingForClose = True veto = c.frame.promptForSave()

  > finally:
  >   c.promptingForClose = False
  > if veto:
  >   g.es_print('Cancelling reload-outline command') return

  > # Save the file. c.save() g.app.recentFilesManager.writeRecentFilesFile(c)

  # Remember old_index, the outline's position in the QTabbledWidget. dw = c.frame.top stacked_widget = dw.parent() tab_widget = dw.leo_master stacked_layout = None for w in stacked_widget.children():

  > if isinstance(w, QtWidgets.QStackedLayout):
  >   stacked_layout = w break

  else:
    g.trace('Can not happen: no QStackedLayout') return

  # Remember the old values. old_index = stacked_layout.indexOf(dw) tab_names = [tab_widget.tabText(i) for i in range(tab_widget.count())]

  # Completely close the outline. g.doHook("close-frame", c=c) frame = c.frame if frame in g.app.windowList:

  > g.app.destroyWindow(frame) g.app.windowList.remove(frame)

  else:
    g.app.forgetOpenFile(fn=c.fileName()) # #69.

  # Open the new outline. g.openWithFileName(fileName=c.fileName())

  # Do nothing more if the index has not changed. new_index = stacked_layout.indexOf(dw) if new_index == old_index:

  > return

  # Put dw in the proper place. stacked_layout.removeWidget(dw) stacked_layout.insertWidget(old_index, dw)

  # Fix all tab names. for i, name in enumerate(tab_names):

  > tab_widget.setTabText(i, name)

  # Select the proper tab. tab_widget.setCurrentIndex(old_index)