mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 11:22:28 +12:00
Fix match and case syntax for python 3.9 and below
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
parent
13486ad083
commit
1933d53c1c
|
@ -263,58 +263,54 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
self.actDelete,
|
self.actDelete,
|
||||||
self.actRename]:
|
self.actRename]:
|
||||||
i.setEnabled(tabIsEditor)
|
i.setEnabled(tabIsEditor)
|
||||||
match self.tabMain.currentIndex():
|
tabIndex = self.tabMain.currentIndex()
|
||||||
case self.TabPersos:
|
|
||||||
selectedCharacters = self.lstCharacters.currentCharacters()
|
|
||||||
characterSelectionIsEmpty = not any(selectedCharacters)
|
|
||||||
|
|
||||||
if characterSelectionIsEmpty:
|
if tabIndex == self.TabPersos:
|
||||||
self.pushHistory(("character", None))
|
selectedCharacters = self.lstCharacters.currentCharacters()
|
||||||
self._previousSelectionEmpty = True
|
characterSelectionIsEmpty = not any(selectedCharacters)
|
||||||
else:
|
|
||||||
character = selectedCharacters[0]
|
|
||||||
self.pushHistory(("character", character.ID()))
|
|
||||||
self._previousSelectionEmpty = False
|
|
||||||
|
|
||||||
case self.TabPlots:
|
if characterSelectionIsEmpty:
|
||||||
id = self.lstPlots.currentPlotID()
|
self.pushHistory(("character", None))
|
||||||
self.pushHistory(("plot", id))
|
self._previousSelectionEmpty = True
|
||||||
self._previousSelectionEmpty = id is None
|
else:
|
||||||
|
character = selectedCharacters[0]
|
||||||
case self.TabWorld:
|
self.pushHistory(("character", character.ID()))
|
||||||
index = self.mdlWorld.selectedIndex()
|
|
||||||
|
|
||||||
if index.isValid():
|
|
||||||
id = self.mdlWorld.ID(index)
|
|
||||||
self.pushHistory(("world", id))
|
|
||||||
self._previousSelectionEmpty = id is not None
|
|
||||||
else:
|
|
||||||
self.pushHistory(("world", None))
|
|
||||||
self._previousSelectionEmpty = True
|
|
||||||
|
|
||||||
case self.TabOutline:
|
|
||||||
index = self.treeOutlineOutline.selectionModel().currentIndex()
|
|
||||||
if index.isValid():
|
|
||||||
id = self.mdlOutline.ID(index)
|
|
||||||
self.pushHistory(("outline", id))
|
|
||||||
self._previousSelectionEmpty = id is not None
|
|
||||||
else:
|
|
||||||
self.pushHistory(("outline", None))
|
|
||||||
self._previousSelectionEmpty = False
|
|
||||||
|
|
||||||
case self.TabRedac:
|
|
||||||
index = self.treeRedacOutline.selectionModel().currentIndex()
|
|
||||||
if index.isValid():
|
|
||||||
id = self.mdlOutline.ID(index)
|
|
||||||
self.pushHistory(("redac", id))
|
|
||||||
self._previousSelectionEmpty = id is not None
|
|
||||||
else:
|
|
||||||
self.pushHistory(("redac", None))
|
|
||||||
self._previousSelectionEmpty = False
|
|
||||||
|
|
||||||
case _:
|
|
||||||
self.pushHistory(("main", self.tabMain.currentIndex()))
|
|
||||||
self._previousSelectionEmpty = False
|
self._previousSelectionEmpty = False
|
||||||
|
elif tabIndex == self.TabPlots:
|
||||||
|
id = self.lstPlots.currentPlotID()
|
||||||
|
self.pushHistory(("plot", id))
|
||||||
|
self._previousSelectionEmpty = id is None
|
||||||
|
elif tabIndex == self.TabWorld:
|
||||||
|
index = self.mdlWorld.selectedIndex()
|
||||||
|
|
||||||
|
if index.isValid():
|
||||||
|
id = self.mdlWorld.ID(index)
|
||||||
|
self.pushHistory(("world", id))
|
||||||
|
self._previousSelectionEmpty = id is not None
|
||||||
|
else:
|
||||||
|
self.pushHistory(("world", None))
|
||||||
|
self._previousSelectionEmpty = True
|
||||||
|
elif tabIndex == self.TabOutline:
|
||||||
|
index = self.treeOutlineOutline.selectionModel().currentIndex()
|
||||||
|
if index.isValid():
|
||||||
|
id = self.mdlOutline.ID(index)
|
||||||
|
self.pushHistory(("outline", id))
|
||||||
|
self._previousSelectionEmpty = id is not None
|
||||||
|
else:
|
||||||
|
self.pushHistory(("outline", None))
|
||||||
|
self._previousSelectionEmpty = False
|
||||||
|
elif tabIndex == self.TabRedac:
|
||||||
|
index = self.treeRedacOutline.selectionModel().currentIndex()
|
||||||
|
if index.isValid():
|
||||||
|
id = self.mdlOutline.ID(index)
|
||||||
|
self.pushHistory(("redac", id))
|
||||||
|
self._previousSelectionEmpty = id is not None
|
||||||
|
else:
|
||||||
|
self.pushHistory(("redac", None))
|
||||||
|
self._previousSelectionEmpty = False
|
||||||
|
else:
|
||||||
|
self.pushHistory(("main", self.tabMain.currentIndex()))
|
||||||
|
self._previousSelectionEmpty = False
|
||||||
|
|
||||||
def focusChanged(self, old, new):
|
def focusChanged(self, old, new):
|
||||||
"""
|
"""
|
||||||
|
@ -841,74 +837,72 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
def navigated(self, event):
|
def navigated(self, event):
|
||||||
if event.entry:
|
if event.entry:
|
||||||
match event.entry[0]:
|
first_entry = event.entry[0]
|
||||||
case "character":
|
|
||||||
if self.tabMain.currentIndex() != self.TabPersos:
|
|
||||||
self.tabMain.setCurrentIndex(self.TabPersos)
|
|
||||||
|
|
||||||
if event.entry[1] is None:
|
if first_entry == "character":
|
||||||
self.lstCharacters.setCurrentItem(None)
|
if self.tabMain.currentIndex() != self.TabPersos:
|
||||||
self.lstCharacters.clearSelection()
|
self.tabMain.setCurrentIndex(self.TabPersos)
|
||||||
else:
|
|
||||||
if self.lstCharacters.currentCharacterID() != event.entry[1]:
|
|
||||||
char = self.lstCharacters.getItemByID(event.entry[1])
|
|
||||||
if char != None:
|
|
||||||
self.lstCharacters.clearSelection()
|
|
||||||
self.lstCharacters.setCurrentItem(char)
|
|
||||||
case "plot":
|
|
||||||
if self.tabMain.currentIndex() != self.TabPlots:
|
|
||||||
self.tabMain.setCurrentIndex(self.TabPlots)
|
|
||||||
|
|
||||||
if event.entry[1] is None:
|
if event.entry[1] is None:
|
||||||
self.lstPlots.setCurrentItem(None)
|
self.lstCharacters.setCurrentItem(None)
|
||||||
else:
|
self.lstCharacters.clearSelection()
|
||||||
index = self.lstPlots.currentPlotIndex()
|
else:
|
||||||
if index and index.row() != event.entry[1]:
|
if self.lstCharacters.currentCharacterID() != event.entry[1]:
|
||||||
plot = self.lstPlots.getItemByID(event.entry[1])
|
char = self.lstCharacters.getItemByID(event.entry[1])
|
||||||
if plot != None:
|
if char != None:
|
||||||
self.lstPlots.setCurrentItem(plot)
|
self.lstCharacters.clearSelection()
|
||||||
case "world":
|
self.lstCharacters.setCurrentItem(char)
|
||||||
if self.tabMain.currentIndex() != self.TabWorld:
|
elif first_entry == "plot":
|
||||||
self.tabMain.setCurrentIndex(self.TabWorld)
|
if self.tabMain.currentIndex() != self.TabPlots:
|
||||||
|
self.tabMain.setCurrentIndex(self.TabPlots)
|
||||||
|
|
||||||
if event.entry[1] is None:
|
if event.entry[1] is None:
|
||||||
self.treeWorld.selectionModel().clear()
|
self.lstPlots.setCurrentItem(None)
|
||||||
else:
|
else:
|
||||||
index = self.mdlWorld.selectedIndex()
|
index = self.lstPlots.currentPlotIndex()
|
||||||
if index and self.mdlWorld.ID(index) != event.entry[1]:
|
if index and index.row() != event.entry[1]:
|
||||||
world = self.mdlWorld.indexByID(event.entry[1])
|
plot = self.lstPlots.getItemByID(event.entry[1])
|
||||||
if world != None:
|
if plot != None:
|
||||||
self.treeWorld.setCurrentIndex(world)
|
self.lstPlots.setCurrentItem(plot)
|
||||||
|
elif first_entry == "world":
|
||||||
|
if self.tabMain.currentIndex() != self.TabWorld:
|
||||||
|
self.tabMain.setCurrentIndex(self.TabWorld)
|
||||||
|
|
||||||
case "outline":
|
if event.entry[1] is None:
|
||||||
if self.tabMain.currentIndex() != self.TabOutline:
|
self.treeWorld.selectionModel().clear()
|
||||||
self.tabMain.setCurrentIndex(self.TabOutline)
|
else:
|
||||||
|
index = self.mdlWorld.selectedIndex()
|
||||||
|
if index and self.mdlWorld.ID(index) != event.entry[1]:
|
||||||
|
world = self.mdlWorld.indexByID(event.entry[1])
|
||||||
|
if world != None:
|
||||||
|
self.treeWorld.setCurrentIndex(world)
|
||||||
|
elif first_entry == "outline":
|
||||||
|
if self.tabMain.currentIndex() != self.TabOutline:
|
||||||
|
self.tabMain.setCurrentIndex(self.TabOutline)
|
||||||
|
|
||||||
if event.entry[1] is None:
|
if event.entry[1] is None:
|
||||||
self.treeOutlineOutline.selectionModel().clear()
|
self.treeOutlineOutline.selectionModel().clear()
|
||||||
else:
|
else:
|
||||||
index = self.treeOutlineOutline.selectionModel().currentIndex()
|
index = self.treeOutlineOutline.selectionModel().currentIndex()
|
||||||
if index and self.mdlOutline.ID(index) != event.entry[1]:
|
if index and self.mdlOutline.ID(index) != event.entry[1]:
|
||||||
outline = self.mdlOutline.getIndexByID(event.entry[1])
|
outline = self.mdlOutline.getIndexByID(event.entry[1])
|
||||||
if outline is not None:
|
if outline is not None:
|
||||||
self.treeOutlineOutline.setCurrentIndex(outline)
|
self.treeOutlineOutline.setCurrentIndex(outline)
|
||||||
|
elif first_entry == "redac":
|
||||||
|
if self.tabMain.currentIndex() != self.TabRedac:
|
||||||
|
self.tabMain.setCurrentIndex(self.TabRedac)
|
||||||
|
|
||||||
case "redac":
|
if event.entry[1] is None:
|
||||||
if self.tabMain.currentIndex() != self.TabRedac:
|
self.treeRedacOutline.selectionModel().clear()
|
||||||
self.tabMain.setCurrentIndex(self.TabRedac)
|
else:
|
||||||
|
index = self.treeRedacOutline.selectionModel().currentIndex()
|
||||||
if event.entry[1] is None:
|
if index and self.mdlOutline.ID(index) != event.entry[1]:
|
||||||
self.treeRedacOutline.selectionModel().clear()
|
outline = self.mdlOutline.getIndexByID(event.entry[1])
|
||||||
else:
|
if outline is not None:
|
||||||
index = self.treeRedacOutline.selectionModel().currentIndex()
|
self.treeRedacOutline.setCurrentIndex(outline)
|
||||||
if index and self.mdlOutline.ID(index) != event.entry[1]:
|
elif first_entry == "main":
|
||||||
outline = self.mdlOutline.getIndexByID(event.entry[1])
|
if self.tabMain.currentIndex() != event.entry[1]:
|
||||||
if outline is not None:
|
self.lstTabs.setCurrentRow(event.entry[1])
|
||||||
self.treeRedacOutline.setCurrentIndex(outline)
|
|
||||||
|
|
||||||
case "main":
|
|
||||||
if self.tabMain.currentIndex() != event.entry[1]:
|
|
||||||
self.lstTabs.setCurrentRow(event.entry[1])
|
|
||||||
|
|
||||||
self.actBack.setEnabled(event.position > 0)
|
self.actBack.setEnabled(event.position > 0)
|
||||||
self.actForward.setEnabled(event.position < event.count - 1)
|
self.actForward.setEnabled(event.position < event.count - 1)
|
||||||
|
|
Loading…
Reference in a new issue