def test_add_file(self): """ Test the File.save method by adding multiple files """ # Import additional classes that need the app defined first from classes.query import File # Find number of files in project num_files = len(File.filter()) # Create file r = openshot.DummyReader(openshot.Fraction(24, 1), 640, 480, 44100, 2, 30.0) # Parse JSON file_data = json.loads(r.Json()) # Insert into project data query_file = File() query_file.data = file_data query_file.data["path"] = os.path.join(PATH, "images", "openshot.png") query_file.data["media_type"] = "image" query_file.save() self.assertTrue(query_file) self.assertEqual(len(File.filter()), num_files + 1) # Save the file again (which should not change the total # of files) query_file.save() self.assertEqual(len(File.filter()), num_files + 1)
def test_add_file(self): """ Test the File.save method by adding multiple files """ # Import additional classes that need the app defined first from classes.query import File # Find number of files in project num_files = len(File.filter()) # Create file r = openshot.DummyReader(openshot.Fraction(24, 1), 640, 480, 44100, 2, 30.0) # Parse JSON file_data = json.loads(r.Json()) # Insert into project data query_file = File() query_file.data = file_data query_file.data["path"] = os.path.join(PATH, "images", "openshot.png") query_file.data["media_type"] = "image" query_file.save() self.assertTrue(query_file) self.assertEqual(len(File.filter()), num_files + 1) # Save the file again (which should not change the total # of files) query_file.save() self.assertEqual(len(File.filter()), num_files + 1)
def test_filter_File(self): """ Test the File.filter method """ files = File.filter(id=self.file_ids[0]) self.assertTrue(files) # Do not find a File files = File.filter(id="invalidID") self.assertEqual(len(files), 0)
def test_filter_File(self): """ Test the File.filter method """ # Import additional classes that need the app defined first from classes.query import File # Find all Files named file1 files = File.filter(id=TestQueryClass.file_ids[0]) self.assertTrue(files) # Do not find a File files = File.filter(id="invalidID") self.assertEqual(len(files), 0)
def test_filter_File(self): """ Test the File.filter method """ # Import additional classes that need the app defined first from classes.query import File # Find all Files named file1 files = File.filter(id=TestQueryClass.file_ids[0]) self.assertTrue(files) # Do not find a File files = File.filter(id="invalidID") self.assertEqual(len(files), 0)
def test_add_file(self): # Find number of files in project num_files = len(File.filter()) # Create file r = openshot.DummyReader(openshot.Fraction(24, 1), 640, 480, 44100, 2, 30.0) file_data = json.loads(r.Json()) # Insert into project data query_file = File() query_file.data = file_data query_file.data["path"] = os.path.join(info.IMAGES_PATH, "AboutLogo.png") query_file.data["media_type"] = "image" query_file.save() self.assertTrue(query_file) self.assertEqual(len(File.filter()), num_files + 1) # Save the file again (which should not change the total # of files) query_file.save() self.assertEqual(len(File.filter()), num_files + 1)
def currentChanged(self, selected, deselected): # Get selected item self.selected = selected self.deselected = deselected # Get translation object _ = self.app._tr # Clear existing settings self.win.clear_effect_controls() # Get animation details animation = self.get_animation_details() self.selected_template = animation.get("service") # In newer versions of Qt, setting the model invokes the currentChanged signal, # but the selection is -1. So, just do nothing here. if not self.selected_template: return # Assign a new unique id for each template selected self.generateUniqueFolder() # Loop through params for param in animation.get("params", []): log.info(param["title"]) # Is Hidden Param? if param["name"] == "start_frame" or param["name"] == "end_frame": # add value to dictionary self.params[param["name"]] = int(param["default"]) # skip to next param without rendering the controls continue # Create Label widget = None label = QLabel() label.setText(_(param["title"])) label.setToolTip(_(param["title"])) if param["type"] == "spinner": # add value to dictionary self.params[param["name"]] = float(param["default"]) # create spinner widget = QDoubleSpinBox() widget.setMinimum(float(param["min"])) widget.setMaximum(float(param["max"])) widget.setValue(float(param["default"])) widget.setSingleStep(0.01) widget.setToolTip(param["title"]) widget.valueChanged.connect( functools.partial(self.spinner_value_changed, param)) elif param["type"] == "text": # add value to dictionary self.params[param["name"]] = _(param["default"]) # create spinner widget = QLineEdit() widget.setText(_(param["default"])) widget.textChanged.connect( functools.partial(self.text_value_changed, widget, param)) elif param["type"] == "multiline": # add value to dictionary self.params[param["name"]] = _(param["default"]) # create spinner widget = QTextEdit() widget.setText(_(param["default"]).replace("\\n", "\n")) widget.textChanged.connect( functools.partial(self.text_value_changed, widget, param)) elif param["type"] == "dropdown": # add value to dictionary self.params[param["name"]] = param["default"] # create spinner widget = QComboBox() widget.currentIndexChanged.connect( functools.partial(self.dropdown_index_changed, widget, param)) # Add values to dropdown if "project_files" in param["name"]: # override files dropdown param["values"] = {} for file in File.filter(): if file.data["media_type"] in ("image", "video"): (dirName, fileName) = os.path.split(file.data["path"]) (fileBaseName, fileExtension) = os.path.splitext(fileName) if fileExtension.lower() not in (".svg"): param["values"][fileName] = "|".join( (file.data["path"], str(file.data["height"]), str(file.data["width"]), file.data["media_type"], str(file.data["fps"]["num"] / file.data["fps"]["den"]))) # Add normal values box_index = 0 for k, v in sorted(param["values"].items()): # add dropdown item widget.addItem(_(k), v) # select dropdown (if default) if v == param["default"]: widget.setCurrentIndex(box_index) box_index = box_index + 1 if not param["values"]: widget.addItem(_("No Files Found"), "") widget.setEnabled(False) elif param["type"] == "color": # add value to dictionary color = QColor(param["default"]) self.params[param["name"]] = [ color.redF(), color.greenF(), color.blueF() ] widget = QPushButton() widget.setText("") widget.setStyleSheet("background-color: {}".format( param["default"])) widget.clicked.connect( functools.partial(self.color_button_clicked, widget, param)) # Add Label and Widget to the form if (widget and label): self.win.settingsContainer.layout().addRow(label, widget) elif (label): self.win.settingsContainer.layout().addRow(label) # Enable interface self.enable_interface() # Init slider values self.init_slider_values()
def currentChanged(self, selected, deselected): # Get selected item self.selected = selected self.deselected = deselected # Get translation object _ = self.app._tr # Clear existing settings self.win.clear_effect_controls() # Get animation details animation = self.get_animation_details() self.selected_template = animation["service"] # Assign a new unique id for each template selected self.generateUniqueFolder() # Loop through params for param in animation["params"]: log.info(param["title"]) # Is Hidden Param? if param["name"] == "start_frame" or param["name"] == "end_frame": # add value to dictionary self.params[param["name"]] = int(param["default"]) # skip to next param without rendering the controls continue # Create Label widget = None label = QLabel() label.setText(_(param["title"])) label.setToolTip(_(param["title"])) if param["type"] == "spinner": # add value to dictionary self.params[param["name"]] = float(param["default"]) # create spinner widget = QDoubleSpinBox() widget.setMinimum(float(param["min"])) widget.setMaximum(float(param["max"])) widget.setValue(float(param["default"])) widget.setSingleStep(0.01) widget.setToolTip(param["title"]) widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param)) elif param["type"] == "text": # add value to dictionary self.params[param["name"]] = _(param["default"]) # create spinner widget = QLineEdit() widget.setText(_(param["default"])) widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param)) elif param["type"] == "multiline": # add value to dictionary self.params[param["name"]] = _(param["default"]) # create spinner widget = QTextEdit() widget.setText(_(param["default"])) widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param)) elif param["type"] == "dropdown": # add value to dictionary self.params[param["name"]] = param["default"] # create spinner widget = QComboBox() widget.currentIndexChanged.connect(functools.partial(self.dropdown_index_changed, widget, param)) # Add values to dropdown if "project_files" in param["name"]: # override files dropdown param["values"] = {} for file in File.filter(): if file.data["media_type"] in ("image", "video"): (dirName, fileName) = os.path.split(file.data["path"]) (fileBaseName, fileExtension) = os.path.splitext(fileName) if fileExtension.lower() not in (".svg"): param["values"][fileName] = "|".join((file.data["path"], str(file.data["height"]), str(file.data["width"]), file.data["media_type"], str(file.data["fps"]["num"] / file.data["fps"][ "den"]))) # Add normal values box_index = 0 for k, v in sorted(param["values"].items()): # add dropdown item widget.addItem(_(k), v) # select dropdown (if default) if v == param["default"]: widget.setCurrentIndex(box_index) box_index = box_index + 1 if not param["values"]: widget.addItem(_("No Files Found"), "") widget.setEnabled(False) elif param["type"] == "color": # add value to dictionary color = QColor(param["default"]) self.params[param["name"]] = [color.redF(), color.greenF(), color.blueF()] widget = QPushButton() widget.setText("") widget.setStyleSheet("background-color: {}".format(param["default"])) widget.clicked.connect(functools.partial(self.color_button_clicked, widget, param)) # Add Label and Widget to the form if (widget and label): self.win.settingsContainer.layout().addRow(label, widget) elif (label): self.win.settingsContainer.layout().addRow(label) # Enable interface self.enable_interface() # Init slider values self.init_slider_values()
def update_model(self, clear=True): log.info("updating files model.") app = get_app() # Get window to check filters win = app.window _ = app._tr # Skip updates (if needed) if self.ignore_update_signal: return # Clear all items if clear: self.model_ids = {} self.model.clear() # Add Headers self.model.setHorizontalHeaderLabels([_("Thumb"), _("Name"), _("Tags"), "", "", ""]) # Get list of files in project files = File.filter() # get all files # add item for each file for file in files: path, filename = os.path.split(file.data["path"]) tags = "" if "tags" in file.data.keys(): tags = file.data["tags"] name = filename if "name" in file.data.keys(): name = file.data["name"] if not win.actionFilesShowAll.isChecked(): if win.actionFilesShowVideo.isChecked(): if not file.data["media_type"] == "video": continue # to next file, didn't match filter elif win.actionFilesShowAudio.isChecked(): if not file.data["media_type"] == "audio": continue # to next file, didn't match filter elif win.actionFilesShowImage.isChecked(): if not file.data["media_type"] == "image": continue # to next file, didn't match filter if win.filesFilter.text() != "": if not win.filesFilter.text().lower() in filename.lower() \ and not win.filesFilter.text().lower() in tags.lower() \ and not win.filesFilter.text().lower() in name.lower(): continue # Generate thumbnail for file (if needed) if (file.data["media_type"] == "video" or file.data["media_type"] == "image"): # Determine thumb path thumb_path = os.path.join(info.THUMBNAIL_PATH, "{}.png".format(file.id)) # Check if thumb exists if not os.path.exists(thumb_path): try: # Convert path to the correct relative path (based on this folder) file_path = file.absolute_path() # Reload this reader clip = openshot.Clip(file_path) reader = clip.Reader() # Open reader reader.Open() # Determine if video overlay should be applied to thumbnail overlay_path = "" if file.data["media_type"] == "video": overlay_path = os.path.join(info.IMAGES_PATH, "overlay.png") # Check for start and end attributes (optional) thumbnail_frame = 1 if 'start' in file.data.keys(): fps = file.data["fps"] fps_float = float(fps["num"]) / float(fps["den"]) thumbnail_frame = round(float(file.data['start']) * fps_float) + 1 # Save thumbnail reader.GetFrame(thumbnail_frame).Thumbnail(thumb_path, 98, 64, os.path.join(info.IMAGES_PATH, "mask.png"), overlay_path, "#000", False) reader.Close() clip.Close() except: # Handle exception msg = QMessageBox() msg.setText(_("{} is not a valid video, audio, or image file.".format(filename))) msg.exec_() continue else: # Audio file thumb_path = os.path.join(info.PATH, "images", "AudioThumbnail.png") row = [] # Append thumbnail col = QStandardItem() col.setIcon(QIcon(thumb_path)) col.setText((name[:9] + '...') if len(name) > 10 else name) col.setToolTip(filename) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled) row.append(col) # Append Filename col = QStandardItem("Name") col.setData(filename, Qt.DisplayRole) col.setText((name[:20] + '...') if len(name) > 15 else name) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Tags col = QStandardItem("Tags") col.setData(tags, Qt.DisplayRole) col.setText(tags) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Media Type col = QStandardItem("Type") col.setData(file.data["media_type"], Qt.DisplayRole) col.setText(file.data["media_type"]) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Path col = QStandardItem("Path") col.setData(path, Qt.DisplayRole) col.setText(path) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled) row.append(col) # Append ID col = QStandardItem("ID") col.setData(file.data["id"], Qt.DisplayRole) col.setText(file.data["id"]) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled) row.append(col) # Append ROW to MODEL (if does not already exist in model) if not file.data["id"] in self.model_ids: self.model.appendRow(row) self.model_ids[file.data["id"]] = file.data["id"] # Process events in QT (to keep the interface responsive) app.processEvents() # Refresh view and filters (to hide or show this new item) get_app().window.resize_contents()
def update_model(self, clear=True): log.info("updating files model.") app = get_app() # Get window to check filters win = app.window _ = app._tr # Skip updates (if needed) if self.ignore_update_signal: return # Clear all items if clear: self.model_ids = {} self.model.clear() # Add Headers self.model.setHorizontalHeaderLabels( [_("Thumb"), _("Name"), _("Tags"), "", "", ""]) # Get list of files in project files = File.filter() # get all files # add item for each file for file in files: path, filename = os.path.split(file.data["path"]) tags = "" if "tags" in file.data.keys(): tags = file.data["tags"] name = filename if "name" in file.data.keys(): name = file.data["name"] if not win.actionFilesShowAll.isChecked(): if win.actionFilesShowVideo.isChecked(): if not file.data["media_type"] == "video": continue # to next file, didn't match filter elif win.actionFilesShowAudio.isChecked(): if not file.data["media_type"] == "audio": continue # to next file, didn't match filter elif win.actionFilesShowImage.isChecked(): if not file.data["media_type"] == "image": continue # to next file, didn't match filter if win.filesFilter.text() != "": if not win.filesFilter.text().lower() in filename.lower() \ and not win.filesFilter.text().lower() in tags.lower() \ and not win.filesFilter.text().lower() in name.lower(): continue # Generate thumbnail for file (if needed) if (file.data["media_type"] == "video" or file.data["media_type"] == "image"): # Determine thumb path thumb_path = os.path.join(info.THUMBNAIL_PATH, "{}.png".format(file.id)) # Check if thumb exists if not os.path.exists(thumb_path): try: # Convert path to the correct relative path (based on this folder) file_path = file.absolute_path() # Reload this reader clip = openshot.Clip(file_path) reader = clip.Reader() # Open reader reader.Open() # Determine if video overlay should be applied to thumbnail overlay_path = "" if file.data["media_type"] == "video": overlay_path = os.path.join( info.IMAGES_PATH, "overlay.png") # Check for start and end attributes (optional) thumbnail_frame = 1 if 'start' in file.data.keys(): fps = file.data["fps"] fps_float = float(fps["num"]) / float(fps["den"]) thumbnail_frame = round( float(file.data['start']) * fps_float) + 1 # Save thumbnail reader.GetFrame(thumbnail_frame).Thumbnail( thumb_path, 98, 64, os.path.join(info.IMAGES_PATH, "mask.png"), overlay_path, "#000", False) reader.Close() clip.Close() except: # Handle exception msg = QMessageBox() msg.setText( _("{} is not a valid video, audio, or image file.". format(filename))) msg.exec_() continue else: # Audio file thumb_path = os.path.join(info.PATH, "images", "AudioThumbnail.png") row = [] # Append thumbnail col = QStandardItem() col.setIcon(QIcon(thumb_path)) col.setText((name[:9] + '...') if len(name) > 10 else name) col.setToolTip(filename) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled) row.append(col) # Append Filename col = QStandardItem("Name") col.setData(filename, Qt.DisplayRole) col.setText((name[:20] + '...') if len(name) > 15 else name) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Tags col = QStandardItem("Tags") col.setData(tags, Qt.DisplayRole) col.setText(tags) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Media Type col = QStandardItem("Type") col.setData(file.data["media_type"], Qt.DisplayRole) col.setText(file.data["media_type"]) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Path col = QStandardItem("Path") col.setData(path, Qt.DisplayRole) col.setText(path) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled) row.append(col) # Append ID col = QStandardItem("ID") col.setData(file.data["id"], Qt.DisplayRole) col.setText(file.data["id"]) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled) row.append(col) # Append ROW to MODEL (if does not already exist in model) if not file.data["id"] in self.model_ids: self.model.appendRow(row) self.model_ids[file.data["id"]] = file.data["id"] # Process events in QT (to keep the interface responsive) app.processEvents() # Refresh view and filters (to hide or show this new item) get_app().window.resize_contents()
def update_model(self, clear=True): log.info("updating files model.") app = get_app() # Get window to check filters win = app.window _ = app._tr # Skip updates (if needed) if self.ignore_update_signal: return # Clear all items if clear: self.model_ids = {} self.model.clear() # Add Headers self.model.setHorizontalHeaderLabels( ["", _("Name"), _("Tags"), "", "", ""]) # Get list of files in project files = File.filter() # get all files # add item for each file for file in files: path, filename = os.path.split(file.data["path"]) tags = "" if "tags" in file.data.keys(): tags = file.data["tags"] name = filename if "name" in file.data.keys(): name = file.data["name"] if not win.actionFilesShowAll.isChecked(): if win.actionFilesShowVideo.isChecked(): if not file.data["media_type"] == "video": continue # to next file, didn't match filter elif win.actionFilesShowAudio.isChecked(): if not file.data["media_type"] == "audio": continue # to next file, didn't match filter elif win.actionFilesShowImage.isChecked(): if not file.data["media_type"] == "image": continue # to next file, didn't match filter if win.filesFilter.text() != "": if not win.filesFilter.text().lower() in filename.lower() \ and not win.filesFilter.text().lower() in tags.lower() \ and not win.filesFilter.text().lower() in name.lower(): continue # Generate thumbnail for file (if needed) if (file.data["media_type"] == "video" or file.data["media_type"] == "image"): # Check for start and end attributes (optional) thumbnail_frame = 1 if 'start' in file.data.keys(): fps = file.data["fps"] fps_float = float(fps["num"]) / float(fps["den"]) thumbnail_frame = round( float(file.data['start']) * fps_float) + 1 # Determine thumb path (default value... a guess) thumb_path = os.path.join( info.THUMBNAIL_PATH, "%s-%s.png" % (file.id, thumbnail_frame)) # Connect to thumbnail server and get image thumb_server_details = get_app( ).window.http_server_thread.server_address thumb_address = "http://%s:%s/thumbnails/%s/%s/path/" % ( thumb_server_details[0], thumb_server_details[1], file.id, thumbnail_frame) r = get(thumb_address) if r.ok: # Update thumbnail path to real one thumb_path = r.text else: # Audio file thumb_path = os.path.join(info.PATH, "images", "AudioThumbnail.png") row = [] # Append thumbnail col = QStandardItem() col.setIcon(QIcon(thumb_path)) col.setText(name) col.setToolTip(filename) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled) row.append(col) # Append Filename col = QStandardItem("Name") col.setData(filename, Qt.DisplayRole) col.setText(name) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Tags col = QStandardItem("Tags") col.setData(tags, Qt.DisplayRole) col.setText(tags) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Media Type col = QStandardItem("Type") col.setData(file.data["media_type"], Qt.DisplayRole) col.setText(file.data["media_type"]) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt.ItemIsEditable) row.append(col) # Append Path col = QStandardItem("Path") col.setData(path, Qt.DisplayRole) col.setText(path) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled) row.append(col) # Append ID col = QStandardItem("ID") col.setData(file.data["id"], Qt.DisplayRole) col.setText(file.data["id"]) col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | Qt.ItemIsDragEnabled) row.append(col) # Append ROW to MODEL (if does not already exist in model) if not file.data["id"] in self.model_ids: self.model.appendRow(row) self.model_ids[file.data["id"]] = file.data["id"] # Process events in QT (to keep the interface responsive) app.processEvents() # Refresh view and filters (to hide or show this new item) get_app().window.resize_contents() # Emit signal self.model.ModelRefreshed.emit()
def update_model(self, clear=True, delete_file_id=None): log.debug("updating files model.") app = get_app() self.ignore_updates = True # Translations _ = app._tr # Delete a file (if delete_file_id passed in) if delete_file_id in self.model_ids: # Use the persistent index we stored to find the row id_index = self.model_ids[delete_file_id] # sanity check if not id_index.isValid() or delete_file_id != id_index.data(): log.warning("Couldn't remove {} from model!".format(delete_file_id)) return # Delete row from model row_num = id_index.row() self.model.removeRows(row_num, 1, id_index.parent()) self.model.submit() self.model_ids.pop(delete_file_id) # Clear all items if clear: self.model_ids = {} self.model.clear() # Add Headers self.model.setHorizontalHeaderLabels(["", _("Name"), _("Tags")]) # Get list of files in project files = File.filter() # get all files # add item for each file row_added_count = 0 for file in files: id = file.data["id"] if id in self.model_ids and self.model_ids[id].isValid(): # Ignore files that already exist in model continue path, filename = os.path.split(file.data["path"]) tags = file.data.get("tags", "") name = file.data.get("name", filename) media_type = file.data.get("media_type") # Generate thumbnail for file (if needed) if media_type in ["video", "image"]: # Check for start and end attributes (optional) thumbnail_frame = 1 if 'start' in file.data: fps = file.data["fps"] fps_float = float(fps["num"]) / float(fps["den"]) thumbnail_frame = round(float(file.data['start']) * fps_float) + 1 # Get thumb path thumb_icon = QIcon(self.get_thumb_path(file.id, thumbnail_frame)) else: # Audio file thumb_icon = QIcon(os.path.join(info.PATH, "images", "AudioThumbnail.svg")) row = [] flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsDragEnabled | Qt. ItemNeverHasChildren # Append thumbnail col = QStandardItem(thumb_icon, name) col.setToolTip(filename) col.setFlags(flags) row.append(col) # Append Filename col = QStandardItem(name) col.setFlags(flags | Qt.ItemIsEditable) row.append(col) # Append Tags col = QStandardItem(tags) col.setFlags(flags | Qt.ItemIsEditable) row.append(col) # Append Media Type col = QStandardItem(media_type) col.setFlags(flags) row.append(col) # Append Path col = QStandardItem(path) col.setFlags(flags) row.append(col) # Append ID col = QStandardItem(id) col.setFlags(flags | Qt.ItemIsUserCheckable) row.append(col) # Append ROW to MODEL (if does not already exist in model) if id not in self.model_ids: self.model.appendRow(row) # Link the file ID hash to that column of the table row by persistent index self.model_ids[id] = QPersistentModelIndex(row[5].index()) row_added_count += 1 if row_added_count % 2 == 0: # Update every X items get_app().processEvents(QEventLoop.ExcludeUserInputEvents) # Refresh view and filters (to hide or show this new item) get_app().window.resize_contents() self.ignore_updates = False # Emit signal when model is updated self.ModelRefreshed.emit()