Skip to content

Commit

Permalink
use action for empty message and add icons to generator table menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl committed May 12, 2017
1 parent 7b804ac commit fafe165
Show file tree
Hide file tree
Showing 5 changed files with 42,857 additions and 40,880 deletions.
14 changes: 10 additions & 4 deletions src/urh/models/GeneratorTableModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from urh import constants
from urh.models.ProtocolTreeItem import ProtocolTreeItem
from urh.models.TableModel import TableModel
from urh.signalprocessing.Message import Message
from urh.signalprocessing.ProtocolAnalyzer import ProtocolAnalyzer
from urh.signalprocessing.ProtocolAnalyzerContainer import ProtocolAnalyzerContainer
from urh.signalprocessing.encoder import Encoder
from urh.ui.actions.Clear import Clear
Expand Down Expand Up @@ -109,10 +111,14 @@ def duplicate_row(self, row: int):
self.update()

def add_empty_row_behind(self, row_index: int, num_bits: int):
self.protocol.insert_empty_message(row=row_index+1,
pause=constants.SETTINGS.value("default_fuzzing_pause", 10**6, int),
num_bits=num_bits)
self.update()
message = Message(plain_bits=[0]*num_bits,
pause=constants.SETTINGS.value("default_fuzzing_pause", 10**6, int),
message_type=self.protocol.default_message_type)

tmp_protocol = ProtocolAnalyzer(None)
tmp_protocol.messages = [message]
undo_action = InsertBitsAndPauses(self.protocol, row_index+1, tmp_protocol)
self.undo_stack.push(undo_action)

def get_selected_label_index(self, row: int, column: int):
if self.row_count == 0:
Expand Down
7 changes: 0 additions & 7 deletions src/urh/signalprocessing/ProtocolAnalyzerContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ def duplicate_line(self, row: int):
except Exception as e:
logger.error("Duplicating line ", str(e))

def insert_empty_message(self, row: int, pause: int, num_bits: int):
try:
msg = Message([0]*num_bits, pause=pause, message_type=self.default_message_type)
self.messages.insert(row, msg)
except Exception as e:
logger.error(str(e))

def fuzz(self, mode: FuzzMode, default_pause=None):
result = []
appd_result = result.append
Expand Down
2 changes: 1 addition & 1 deletion src/urh/ui/actions/InsertBitsAndPauses.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, proto_analyzer_container: ProtocolAnalyzerContainer, index: i
if self.index == -1 or self.index > len(self.proto_analyzer_container.messages):
self.index = len(self.proto_analyzer_container.messages)

self.setText("Insert Bits at index {0:d}".format(self.index))
self.setText("Insert data at index {0:d}".format(self.index))
self.num_messages = 0

def redo(self):
Expand Down
24 changes: 14 additions & 10 deletions src/urh/ui/views/GeneratorTableView.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,37 @@ def create_context_menu(self) -> QMenu:

if self.model().row_count > 0:
if selected_label_index == -1:
fuzzing_action = menu.addAction("Create Fuzzing Label...")
fuzzing_action = menu.addAction("Create fuzzing Label...")
fuzzing_action.setIcon(QIcon.fromTheme("list-add"))
else:
fuzzing_action = menu.addAction("Edit Fuzzing Label...")
fuzzing_action = menu.addAction("Edit fuzzing Label...")
fuzzing_action.setIcon(QIcon.fromTheme("configure"))

fuzzing_action.triggered.connect(self.on_fuzzing_action_triggered)
menu.addSeparator()

add_message_action = menu.addAction("Add empty message...")
add_message_action.setIcon(QIcon.fromTheme("list-add"))
add_message_action.setIcon(QIcon.fromTheme("edit-table-insert-row-below"))
add_message_action.triggered.connect(self.on_add_message_action_triggered)

if self.model().row_count > 0:
column_menu = menu.addMenu("Add column")
duplicate_action = menu.addAction("Duplicate line")
duplicate_action.setIcon(QIcon.fromTheme("edit-table-insert-row-under"))
duplicate_action.triggered.connect(self.on_duplicate_action_triggered)

column_menu = menu.addMenu("Insert column")

insert_column_left_action = column_menu.addAction("on the left")
insert_column_left_action.triggered.connect(self.on_insert_column_left_action_triggered)
insert_column_left_action.setIcon(QIcon.fromTheme("edit-table-insert-column-left"))
insert_column_right_action = column_menu.addAction("on the right")
insert_column_right_action.setIcon(QIcon.fromTheme("edit-table-insert-column-right"))
insert_column_right_action.triggered.connect(self.on_insert_column_right_action_triggered)

duplicate_action = menu.addAction("Duplicate Line")
duplicate_action.triggered.connect(self.on_duplicate_action_triggered)

menu.addSeparator()
clear_action = menu.addAction("Clear Table")
clear_action = menu.addAction("Clear table")
clear_action.triggered.connect(self.on_clear_action_triggered)
clear_action.setIcon(QIcon.fromTheme("edit-clear"))

self.encoding_actions = {}

Expand Down Expand Up @@ -245,5 +251,3 @@ def on_add_message_action_triggered(self):
self.tr("Number of bits:"), 42, 1)
if ok:
self.model().add_empty_row_behind(row, num_bits)
if self.model().rowCount() == 1:
self.resize_columns()
Loading

0 comments on commit fafe165

Please sign in to comment.