Skip to content

Commit 9fc70b3

Browse files
committed
Added automerge feature based on cmds start and end scenarios
1 parent 8b154be commit 9fc70b3

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

core/table_controller.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def paste(self, model, start_index):
5858

5959
data = []
6060
for line in clipboard_text.split('\n'):
61-
line = line.strip()
6261
if line:
6362
if '\t' in line:
6463
cells = line.split('\t')

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
app = QApplication(sys.argv)
1010
app.setApplicationName("Test Case Editor")
1111
app.setApplicationVersion("0.3.0")
12-
app.setWindowIcon(QIcon("resources/testeditor_logo.png"))
12+
app.setWindowIcon(QIcon("resources/testeditor_logo.PNG"))
1313
style_sheet = get_stylesheet()
1414
app.setStyleSheet(style_sheet)
1515
editor = MainWindow()

ui/table.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ def setup_table(self):
4040
self.table.setAlternatingRowColors(False)
4141
self.table.setSortingEnabled(False)
4242

43+
self.model.rowsInserted.connect(self.merge_cells)
44+
self.model.rowsRemoved.connect(self.merge_cells)
45+
self.model.dataChanged.connect(self._on_data_changed_commands)
46+
self.model.modelReset.connect(self.merge_cells)
47+
48+
self.merge_cells()
49+
4350
def auto_adjust_cells(self):
4451
self.table.resizeColumnsToContents()
4552

@@ -163,3 +170,42 @@ def delete_rows(self):
163170
return
164171
if rows:
165172
self.deleteRowsRequested.emit(rows)
173+
174+
def merge_cells(self):
175+
self.table.clearSpans()
176+
177+
model = self.model
178+
command_col = 6
179+
desc_col = 3
180+
181+
blocks = []
182+
start_row_stack = []
183+
184+
start_row = 3
185+
end_row = model.rowCount() - 3
186+
if end_row < start_row:
187+
return
188+
189+
row = 3
190+
for row in range(row, end_row):
191+
command_index = model.index(row, command_col)
192+
command = model.data(command_index, Qt.ItemDataRole.DisplayRole)
193+
194+
if command == "StartScenario":
195+
start_row_stack.append(row)
196+
197+
elif command == "EndScenario":
198+
if start_row_stack:
199+
start_row = start_row_stack.pop()
200+
blocks.append((start_row, row))
201+
202+
for start, end in blocks:
203+
span_size = end - start + 1
204+
if span_size > 1:
205+
self.table.setSpan(start, desc_col, span_size, 1)
206+
207+
def _on_data_changed_commands(self, topLeft, bottomRight, roles):
208+
command_col = 6
209+
210+
if topLeft.column() <= command_col <= bottomRight.column():
211+
self.merge_cells()

0 commit comments

Comments
 (0)