inc delete tracks
This commit is contained in:
@@ -153,8 +153,8 @@ class PatternDetailsScreen(Screen):
|
|||||||
self.column_key_audio_layout = self.audioStreamsTable.add_column("Layout", width=20)
|
self.column_key_audio_layout = self.audioStreamsTable.add_column("Layout", width=20)
|
||||||
self.column_key_audio_language = self.audioStreamsTable.add_column("Language", width=20)
|
self.column_key_audio_language = self.audioStreamsTable.add_column("Language", width=20)
|
||||||
self.column_key_audio_title = self.audioStreamsTable.add_column("Title", width=30)
|
self.column_key_audio_title = self.audioStreamsTable.add_column("Title", width=30)
|
||||||
self.column_key_subtitle_default = self.audioStreamsTable.add_column("Default", width=10)
|
self.column_key_audio_default = self.audioStreamsTable.add_column("Default", width=10)
|
||||||
self.column_key_subtitle_forced = self.audioStreamsTable.add_column("Forced", width=10)
|
self.column_key_audio_forced = self.audioStreamsTable.add_column("Forced", width=10)
|
||||||
|
|
||||||
self.audioStreamsTable.cursor_type = 'row'
|
self.audioStreamsTable.cursor_type = 'row'
|
||||||
|
|
||||||
@@ -357,7 +357,42 @@ class PatternDetailsScreen(Screen):
|
|||||||
self.subtitleStreamsTable.add_row(*map(str, row))
|
self.subtitleStreamsTable.add_row(*map(str, row))
|
||||||
|
|
||||||
|
|
||||||
def handle_edit_stream(self):
|
def handle_edit_stream(self, trackDescriptor):
|
||||||
pass
|
|
||||||
def handle_delete_stream(self):
|
try:
|
||||||
pass
|
if trackDescriptor['type'] == TrackType.AUDIO:
|
||||||
|
|
||||||
|
row_key, col_key = self.audioStreamsTable.coordinate_to_cell_key(self.audioStreamsTable.cursor_coordinate)
|
||||||
|
|
||||||
|
self.audioStreamsTable.update_cell(row_key, self.column_key_audio_language, trackDescriptor['language'].label())
|
||||||
|
self.audioStreamsTable.update_cell(row_key, self.column_key_audio_title, trackDescriptor['title'])
|
||||||
|
self.audioStreamsTable.update_cell(row_key, self.column_key_audio_default, 'Yes' if TrackDisposition.DEFAULT in trackDescriptor['disposition_list'] else 'No')
|
||||||
|
self.audioStreamsTable.update_cell(row_key, self.column_key_audio_forced, 'Yes' if TrackDisposition.FORCED in trackDescriptor['disposition_list'] else 'No')
|
||||||
|
|
||||||
|
if trackDescriptor['type'] == TrackType.SUBTITLE:
|
||||||
|
|
||||||
|
row_key, col_key = self.subtitleStreamsTable.coordinate_to_cell_key(self.subtitleStreamsTable.cursor_coordinate)
|
||||||
|
|
||||||
|
self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_language, trackDescriptor['language'].label())
|
||||||
|
self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_title, trackDescriptor['title'])
|
||||||
|
self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_default, 'Yes' if TrackDisposition.DEFAULT in trackDescriptor['disposition_list'] else 'No')
|
||||||
|
self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_forced, 'Yes' if TrackDisposition.FORCED in trackDescriptor['disposition_list'] else 'No')
|
||||||
|
|
||||||
|
except CellDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def handle_delete_stream(self, trackDescriptor):
|
||||||
|
|
||||||
|
try:
|
||||||
|
if trackDescriptor['type'] == TrackType.AUDIO:
|
||||||
|
row_key, col_key = self.audioStreamsTable.coordinate_to_cell_key(self.audioStreamsTable.cursor_coordinate)
|
||||||
|
self.audioStreamsTable.remove_row(row_key)
|
||||||
|
|
||||||
|
if trackDescriptor['type'] == TrackType.SUBTITLE:
|
||||||
|
row_key, col_key = self.subtitleStreamsTable.coordinate_to_cell_key(self.subtitleStreamsTable.cursor_coordinate)
|
||||||
|
self.subtitleStreamsTable.remove_row(row_key)
|
||||||
|
|
||||||
|
except CellDoesNotExist:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ class TrackController():
|
|||||||
|
|
||||||
s.add(track)
|
s.add(track)
|
||||||
s.commit()
|
s.commit()
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise click.ClickException(f"TrackController.addTrack(): {repr(ex)}")
|
raise click.ClickException(f"TrackController.addTrack(): {repr(ex)}")
|
||||||
@@ -44,29 +42,32 @@ class TrackController():
|
|||||||
s.close()
|
s.close()
|
||||||
|
|
||||||
|
|
||||||
# def updateTrack(self, trackDescriptor):
|
def updateTrack(self, trackId, trackDescriptor):
|
||||||
#
|
|
||||||
# try:
|
try:
|
||||||
# s = self.Session()
|
s = self.Session()
|
||||||
# q = s.query(Track).filter(Track.id == int(trackId))
|
q = s.query(Track).filter(Track.id == int(trackId))
|
||||||
#
|
|
||||||
# if not q.count():
|
if q.count():
|
||||||
# track = Track(pattern_id = int(trackDescriptor['pattern_id']),
|
|
||||||
# track_type = TrackType(trackDescriptor['type']),
|
track = q.first()
|
||||||
# sub_index = int(trackDescriptor['sub_index']),
|
|
||||||
# language = IsoLanguage(trackDescriptor['language']),
|
track.sub_index = int(trackDescriptor['sub_index'])
|
||||||
# title = str(trackDescriptor['title']),
|
track.language = str(trackDescriptor['language'].threeLetter())
|
||||||
# disposition_flags = TrackDisposition.toFlags(trackDescriptor['disposition_list']))
|
track.title = str(trackDescriptor['title'])
|
||||||
# s.add(track)
|
track.disposition_flags = int(TrackDisposition.toFlags(trackDescriptor['disposition_list']))
|
||||||
# s.commit()
|
|
||||||
# return True
|
s.commit()
|
||||||
# else:
|
|
||||||
# return False
|
return True
|
||||||
#
|
|
||||||
# except Exception as ex:
|
else:
|
||||||
# raise click.ClickException(f"TrackController.updateTrack(): {repr(ex)}")
|
return False
|
||||||
# finally:
|
|
||||||
# s.close()
|
except Exception as ex:
|
||||||
|
raise click.ClickException(f"TrackController.addTrack(): {repr(ex)}")
|
||||||
|
finally:
|
||||||
|
s.close()
|
||||||
|
|
||||||
|
|
||||||
def findAllTracks(self, patternId):
|
def findAllTracks(self, patternId):
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ class TrackDeleteScreen(Screen):
|
|||||||
CSS = """
|
CSS = """
|
||||||
|
|
||||||
Grid {
|
Grid {
|
||||||
grid-size: 2;
|
grid-size: 4 9;
|
||||||
grid-rows: 2 auto;
|
grid-rows: 2 2 2 2 2 2 2 2 2;
|
||||||
grid-columns: 30 330;
|
grid-columns: 30 30 30 30;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 1;
|
padding: 1;
|
||||||
@@ -41,6 +41,12 @@ class TrackDeleteScreen(Screen):
|
|||||||
.two {
|
.two {
|
||||||
column-span: 2;
|
column-span: 2;
|
||||||
}
|
}
|
||||||
|
.three {
|
||||||
|
column-span: 3;
|
||||||
|
}
|
||||||
|
.four {
|
||||||
|
column-span: 4;
|
||||||
|
}
|
||||||
|
|
||||||
.box {
|
.box {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -48,29 +54,26 @@ class TrackDeleteScreen(Screen):
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, trackType : TrackType, trackId = None):
|
def __init__(self, trackId = None):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.context = self.app.getContext()
|
self.context = self.app.getContext()
|
||||||
self.Session = self.context['database_session'] # convenience
|
self.Session = self.context['database_session'] # convenience
|
||||||
|
|
||||||
|
if trackId is None:
|
||||||
|
raise click.ClickException('TrackDeleteScreen.init(): trackId is required to be set')
|
||||||
|
|
||||||
self.__tc = TrackController(context = self.context)
|
self.__tc = TrackController(context = self.context)
|
||||||
# self.__pc = PatternController(context = self.context)
|
|
||||||
# self.__sc = ShowController(context = self.context)
|
|
||||||
|
|
||||||
# self.pattern_obj = self.__pc.getPatternDescriptor(patternId) if patternId is not None else {}
|
self.track_obj = self.__tc.getTrackDescriptor(trackId)
|
||||||
# self.show_obj = self.__sc.getShowDesciptor(showId) if showId is not None else {}
|
|
||||||
|
|
||||||
self.trackType = trackType
|
|
||||||
self.track_obj = {}
|
|
||||||
|
|
||||||
|
|
||||||
def on_mount(self):
|
def on_mount(self):
|
||||||
pass
|
|
||||||
# if self.show_obj:
|
self.query_one("#subindexlabel", Static).update(str(self.track_obj['sub_index']))
|
||||||
# self.query_one("#showlabel", Static).update(f"{self.show_obj['id']} - {self.show_obj['name']} ({self.show_obj['year']})")
|
self.query_one("#patternlabel", Static).update(str(self.track_obj['pattern_id']))
|
||||||
# if self.pattern_obj:
|
self.query_one("#languagelabel", Static).update(str(self.track_obj['language'].label()))
|
||||||
# self.query_one("#patternlabel", Static).update(str(self.pattern_obj['pattern']))
|
self.query_one("#titlelabel", Static).update(str(str(self.track_obj['title'])))
|
||||||
|
|
||||||
|
|
||||||
def compose(self):
|
def compose(self):
|
||||||
@@ -79,20 +82,35 @@ class TrackDeleteScreen(Screen):
|
|||||||
|
|
||||||
with Grid():
|
with Grid():
|
||||||
|
|
||||||
yield Static(f"Are you sure to delete the following {self.trackType.label()} stream?", id="toplabel", classes="two")
|
#1
|
||||||
|
yield Static(f"Are you sure to delete the following {self.track_obj['type'].label()} track?", id="toplabel", classes="four")
|
||||||
|
|
||||||
# yield Static("", classes="two")
|
#2
|
||||||
#
|
yield Static("sub index")
|
||||||
# yield Static("Pattern")
|
yield Static(" ", id="subindexlabel", classes="three")
|
||||||
# yield Static("", id="patternlabel")
|
|
||||||
#
|
|
||||||
# yield Static("", classes="two")
|
|
||||||
#
|
|
||||||
# yield Static("from show")
|
|
||||||
# yield Static("", id="showlabel")
|
|
||||||
|
|
||||||
yield Static("", classes="two")
|
#3
|
||||||
|
yield Static("from pattern")
|
||||||
|
yield Static(" ", id="patternlabel", classes="three")
|
||||||
|
|
||||||
|
#4
|
||||||
|
yield Static(" ", classes="four")
|
||||||
|
|
||||||
|
#5
|
||||||
|
yield Static("Language")
|
||||||
|
yield Static(" ", id="languagelabel", classes="three")
|
||||||
|
|
||||||
|
#6
|
||||||
|
yield Static("Title")
|
||||||
|
yield Static(" ", id="titlelabel", classes="three")
|
||||||
|
|
||||||
|
#7
|
||||||
|
yield Static(" ", classes="four")
|
||||||
|
|
||||||
|
#8
|
||||||
|
yield Static(" ", classes="four")
|
||||||
|
|
||||||
|
#9
|
||||||
yield Button("Delete", id="delete_button")
|
yield Button("Delete", id="delete_button")
|
||||||
yield Button("Cancel", id="cancel_button")
|
yield Button("Cancel", id="cancel_button")
|
||||||
|
|
||||||
@@ -102,20 +120,19 @@ class TrackDeleteScreen(Screen):
|
|||||||
# Event handler for button press
|
# Event handler for button press
|
||||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||||
|
|
||||||
# if event.button.id == "delete_button":
|
if event.button.id == "delete_button":
|
||||||
#
|
|
||||||
# if self.__pc.deletePattern(self.pattern_obj['id']):
|
trackId = self.__tc.findTrack(self.track_obj['pattern_id'], self.track_obj['type'], self.track_obj['sub_index'])
|
||||||
#
|
|
||||||
# screenResult = {}
|
if trackId is not None:
|
||||||
# screenResult['show_id'] = self.show_obj['id']
|
|
||||||
# screenResult['pattern'] = self.pattern_obj['pattern']
|
if self.__tc.deleteTrack(trackId):
|
||||||
#
|
self.dismiss(self.track_obj)
|
||||||
# self.dismiss(screenResult)
|
|
||||||
#
|
else:
|
||||||
# else:
|
#TODO: Meldung
|
||||||
# #TODO: Meldung
|
self.app.pop_screen()
|
||||||
# self.app.pop_screen()
|
|
||||||
#
|
|
||||||
if event.button.id == "cancel_button":
|
if event.button.id == "cancel_button":
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
|
|
||||||
|
|||||||
@@ -90,10 +90,12 @@ class TrackDetailsScreen(Screen):
|
|||||||
self.trackType = self.track_obj['type']
|
self.trackType = self.track_obj['type']
|
||||||
self.subIndex = self.track_obj['sub_index']
|
self.subIndex = self.track_obj['sub_index']
|
||||||
self.pattern_obj = self.__pc.getPatternDescriptor(self.track_obj['pattern_id'])
|
self.pattern_obj = self.__pc.getPatternDescriptor(self.track_obj['pattern_id'])
|
||||||
|
self.track_obj['is_new'] = False
|
||||||
else:
|
else:
|
||||||
self.trackType = trackType
|
self.trackType = trackType
|
||||||
self.subIndex = subIndex
|
self.subIndex = subIndex
|
||||||
self.pattern_obj = self.__pc.getPatternDescriptor(patternId) if patternId is not None else {}
|
self.pattern_obj = self.__pc.getPatternDescriptor(patternId) if patternId is not None else {}
|
||||||
|
self.track_obj['is_new'] = True
|
||||||
|
|
||||||
if self.trackType is None:
|
if self.trackType is None:
|
||||||
raise click.ClickException('Track type is required to be set')
|
raise click.ClickException('Track type is required to be set')
|
||||||
@@ -113,13 +115,20 @@ class TrackDetailsScreen(Screen):
|
|||||||
if self.subIndex is not None:
|
if self.subIndex is not None:
|
||||||
self.query_one("#subindexlabel", Static).update(str(self.subIndex))
|
self.query_one("#subindexlabel", Static).update(str(self.subIndex))
|
||||||
|
|
||||||
|
|
||||||
for d in TrackDisposition:
|
for d in TrackDisposition:
|
||||||
dispositionIsSet = self.track_obj and d in self.track_obj['disposition_list']
|
|
||||||
|
dispositionIsSet = (self.track_obj
|
||||||
|
and 'disposition_list' in self.track_obj.keys()
|
||||||
|
and d in self.track_obj['disposition_list'])
|
||||||
|
|
||||||
disposition = (d.label(), d.index(), dispositionIsSet)
|
disposition = (d.label(), d.index(), dispositionIsSet)
|
||||||
self.query_one("#dispositions_selection_list", SelectionList).add_option(disposition)
|
self.query_one("#dispositions_selection_list", SelectionList).add_option(disposition)
|
||||||
|
|
||||||
if self.track_obj:
|
if 'language' in self.track_obj.keys():
|
||||||
self.query_one("#language_select", Select).value = self.track_obj['language'].label()
|
self.query_one("#language_select", Select).value = self.track_obj['language'].label()
|
||||||
|
|
||||||
|
if 'title' in self.track_obj.keys():
|
||||||
self.query_one("#title_input", Input).value = str(self.track_obj['title'])
|
self.query_one("#title_input", Input).value = str(self.track_obj['title'])
|
||||||
|
|
||||||
|
|
||||||
@@ -158,7 +167,7 @@ class TrackDetailsScreen(Screen):
|
|||||||
with Grid():
|
with Grid():
|
||||||
|
|
||||||
# 1
|
# 1
|
||||||
yield Static(f"Edit {self.trackType.label()} stream" if self.track_obj else f"New {self.trackType.label()} stream", id="toplabel", classes="five")
|
yield Static(f"New {self.trackType.label()} stream" if self.track_obj['is_new'] else f"Edit {self.trackType.label()} stream", id="toplabel", classes="five")
|
||||||
|
|
||||||
# 2
|
# 2
|
||||||
yield Static("for pattern")
|
yield Static("for pattern")
|
||||||
@@ -249,11 +258,22 @@ class TrackDetailsScreen(Screen):
|
|||||||
|
|
||||||
trackDescriptor = self.getTrackDescriptorFromInput()
|
trackDescriptor = self.getTrackDescriptorFromInput()
|
||||||
|
|
||||||
if self.__tc.addTrack(trackDescriptor): #!
|
|
||||||
|
if self.track_obj['is_new']:
|
||||||
|
|
||||||
|
self.__tc.addTrack(trackDescriptor)
|
||||||
self.dismiss(trackDescriptor)
|
self.dismiss(trackDescriptor)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#TODO: Meldung
|
|
||||||
self.app.pop_screen()
|
trackId = self.__tc.findTrack(self.track_obj['pattern_id'], self.track_obj['type'], self.track_obj['sub_index'])
|
||||||
|
|
||||||
|
if self.__tc.updateTrack(trackId, trackDescriptor):
|
||||||
|
self.dismiss(trackDescriptor)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.app.pop_screen()
|
||||||
|
|
||||||
|
|
||||||
if event.button.id == "cancel_button":
|
if event.button.id == "cancel_button":
|
||||||
self.app.pop_screen()
|
self.app.pop_screen()
|
||||||
|
|||||||
Reference in New Issue
Block a user