Skip to content

Commit

Permalink
Adding option to copy transcription source from transcription table
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus committed Nov 9, 2024
1 parent f61701f commit 5451c59
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions buzz/widgets/transcription_tasks_table_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
from PyQt6.QtCore import Qt
from PyQt6.QtCore import pyqtSignal, QModelIndex
from PyQt6.QtSql import QSqlTableModel, QSqlRecord
from PyQt6.QtGui import QKeySequence
from PyQt6.QtWidgets import (
QApplication,
QWidget,
QMenu,
QHeaderView,
Expand Down Expand Up @@ -250,9 +252,26 @@ def save_column_visibility(self):
)
self.settings.end_group()

def copy_selected_fields(self):
selected_text = ""
for row in self.selectionModel().selectedRows():
row_index = row.row()
file_name = self.model().data(self.model().index(row_index, 3))
url = self.model().data(self.model().index(row_index, 14))

Check warning on line 260 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L256-L260

Added lines #L256 - L260 were not covered by tests

selected_text += f"{file_name}{url}\n"

Check warning on line 262 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L262

Added line #L262 was not covered by tests

selected_text = selected_text.rstrip("\n")
QApplication.clipboard().setText(selected_text)

Check warning on line 265 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L264-L265

Added lines #L264 - L265 were not covered by tests

def keyPressEvent(self, event: QtGui.QKeyEvent) -> None:
if event.key() == Qt.Key.Key_Return:
self.return_clicked.emit()

if event.matches(QKeySequence.StandardKey.Copy):
self.copy_selected_fields()
return

Check warning on line 273 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L272-L273

Added lines #L272 - L273 were not covered by tests

super().keyPressEvent(event)

def selected_transcriptions(self) -> List[Transcription]:
Expand Down

0 comments on commit 5451c59

Please sign in to comment.