@@ -399,9 +399,13 @@ def actionTitle_trigger(self, event):
399
399
400
400
def actionEditTitle_trigger (self , event ):
401
401
402
- # Get selected svg title file
403
- selected_file_id = self .selected_files [0 ]
404
- file = File .get (id = selected_file_id )
402
+ # Get requested view item
403
+ index = self .filesView .indexAt (event .pos ())
404
+
405
+ # look up svg title file ID from column 5 of that row
406
+ selected_id = index .model ().sibling (index .row (), 5 , index .parent ()).data ()
407
+
408
+ file = File .get (id = selected_id )
405
409
file_path = file .data .get ("path" )
406
410
407
411
# show dialog for editing title
@@ -431,9 +435,7 @@ def actionDuplicateTitle_trigger(self, event):
431
435
file_path = None
432
436
433
437
# Loop through selected files (set 1 selected file if more than 1)
434
- for file_id in self .selected_files :
435
- # Find matching file
436
- f = File .get (id = file_id )
438
+ for f in self .selected_files ():
437
439
if f .data .get ("path" ).endswith (".svg" ):
438
440
file_path = f .data .get ("path" )
439
441
break
@@ -730,11 +732,11 @@ def actionImportFiles_trigger(self, event):
730
732
731
733
def actionAdd_to_Timeline_trigger (self , event ):
732
734
# Loop through selected files
733
- f = None
734
- files = []
735
- for file_id in self . selected_files :
736
- # Find matching file
737
- files . append ( File . get ( id = file_id ))
735
+ files = self . selected_files ()
736
+
737
+ # Bail if nothing's selected
738
+ if not files :
739
+ return
738
740
739
741
# Get current position of playhead
740
742
fps = get_app ().project .get ("fps" )
@@ -918,14 +920,11 @@ def actionPreview_File_trigger(self, event):
918
920
log .info ('actionPreview_File_trigger' )
919
921
920
922
# Loop through selected files (set 1 selected file if more than 1)
921
- f = None
922
- for file_id in self .selected_files :
923
- # Find matching file
924
- f = File .get (id = file_id )
923
+ f = self .files_model .current_file ()
925
924
926
925
# Bail out if no file selected
927
926
if not f :
928
- log .info ("Preview action failed, selected files: {}" . format ( self . selected_files ) )
927
+ log .info ("Couldn't find current file for preview window" )
929
928
return
930
929
931
930
# show dialog
@@ -1660,14 +1659,11 @@ def actionSplitClip_trigger(self, event):
1660
1659
log .info ("actionSplitClip_trigger" )
1661
1660
1662
1661
# Loop through selected files (set 1 selected file if more than 1)
1663
- f = None
1664
- for file_id in self .selected_files :
1665
- # Find matching file
1666
- f = File .get (id = file_id )
1662
+ f = self .files_model .current_file ()
1667
1663
1668
1664
# Bail out if no file selected
1669
1665
if not f :
1670
- log .warn ("Split clip action failed, selected files: {}" . format ( self . selected_files ) )
1666
+ log .warn ("Split clip action failed, couldn't find current file" )
1671
1667
return
1672
1668
1673
1669
# show dialog
@@ -1684,21 +1680,19 @@ def actionRemove_from_Project_trigger(self, event):
1684
1680
log .info ("actionRemove_from_Project_trigger" )
1685
1681
1686
1682
# Loop through selected files
1687
- for file_id in self .selected_files :
1688
- # Find matching file
1689
- f = File .get (id = file_id )
1690
- if f :
1691
- # Remove file
1692
- f .delete ()
1683
+ for f in self .selected_files ():
1684
+ if not f :
1685
+ continue
1693
1686
1694
- # Find matching clips (if any)
1695
- clips = Clip .filter (file_id = file_id )
1696
- for c in clips :
1697
- # Remove clip
1698
- c .delete ()
1687
+ id = f .data ["id" ]
1688
+ # Remove file
1689
+ f .delete ()
1699
1690
1700
- # Clear selected files
1701
- self .selected_files = []
1691
+ # Find matching clips (if any)
1692
+ clips = Clip .filter (file_id = id )
1693
+ for c in clips :
1694
+ # Remove clip
1695
+ c .delete ()
1702
1696
1703
1697
# Refresh preview
1704
1698
get_app ().window .refreshFrameSignal .emit ()
@@ -1891,11 +1885,11 @@ def actionFullscreen_trigger(self, event):
1891
1885
def actionFile_Properties_trigger (self , event ):
1892
1886
log .info ("Show file properties" )
1893
1887
1894
- # Loop through selected files (set 1 selected file if more than 1 )
1895
- f = None
1896
- for file_id in self . selected_files :
1897
- # Find matching file
1898
- f = File . get ( id = file_id )
1888
+ # Get current selected file (corresponding to menu, if possible )
1889
+ f = self . files_model . current_file ()
1890
+ if not f :
1891
+ log . warning ( "Couldn't find current file for properties window" )
1892
+ return
1899
1893
1900
1894
# show dialog
1901
1895
from windows .file_properties import FileProperties
@@ -1905,7 +1899,7 @@ def actionFile_Properties_trigger(self, event):
1905
1899
if result == QDialog .Accepted :
1906
1900
1907
1901
# BRUTE FORCE approach: go through all clips and update file path
1908
- clips = Clip .filter (file_id = file_id )
1902
+ clips = Clip .filter (file_id = f . data [ "id" ] )
1909
1903
for c in clips :
1910
1904
# update clip
1911
1905
c .data ["reader" ]["path" ] = f .data ["path" ]
@@ -2191,6 +2185,22 @@ def removeSelection(self, item_id, item_type):
2191
2185
# Change selected item in properties view
2192
2186
self .show_property_timer .start ()
2193
2187
2188
+ def selected_files (self ):
2189
+ """ Return a list of File objects for the Project Files dock's selection """
2190
+ return self .files_model .selected_files ()
2191
+
2192
+ def selected_file_ids (self ):
2193
+ """ Return a list of File IDs for the Project Files dock's selection """
2194
+ return self .files_model .selected_file_ids ()
2195
+
2196
+ def current_file (self ):
2197
+ """ Return the Project Files dock's currently-active item as a File object """
2198
+ return self .files_model .current_file ()
2199
+
2200
+ def current_file_id (self ):
2201
+ """ Return the ID of the Project Files dock's currently-active item """
2202
+ return self .files_model .current_file_id ()
2203
+
2194
2204
# Update window settings in setting store
2195
2205
def save_settings (self ):
2196
2206
s = settings .get_settings ()
@@ -2399,7 +2409,6 @@ def setup_toolbars(self):
2399
2409
2400
2410
def clearSelections (self ):
2401
2411
"""Clear all selection containers"""
2402
- self .selected_files = []
2403
2412
self .selected_clips = []
2404
2413
self .selected_transitions = []
2405
2414
self .selected_markers = []
0 commit comments