def _on_choose_stage(self):
    if (not self._choose_stage_popup.isActiveWindow()):
        return Status.OK
    self._choose_stage_popup.close()
    selected_items = self._imported_stages_list.selectedItems()
    for selected_item in selected_items:
        stage_index = self._choose_stage_popup.get_selected_stage_index()
        replacement_stage_name = selected_item.text().split('|')[0][:(- 1)]
        if self._replace_queue:
            stage_indices = list(zip(*self._replace_queue))[1]
            if (stage_index in stage_indices):
                conflict_index = stage_indices.index(stage_index)
                conflict_item = self._replace_queue_list.item(conflict_index)
                self._replace_queue_list.takeItem(self._replace_queue_list.row(conflict_item))
                del self._replace_queue[conflict_index]
            if ((replacement_stage_name, stage_index) in self._replace_queue):
                return Status.OK
        self._choose_stage_popup.set_associated_stage(stage_index, replacement_stage_name)
        item = QListWidgetItem()
        item.setData(self._output_stage_id_key, self._choose_stage_popup.get_stage_id(stage_index))
        item.setData(self._input_filenames_key, selected_item.data(self._input_filenames_key))
        item_text = ((replacement_stage_name + ' -> ') + self._choose_stage_popup.get_stage_name(stage_index))
        item.setText(item_text)
        item.setIcon(QIcon('resources/gray_dot.png'))
        self._replace_queue_list.addItem(item)
        self._replace_queue.append((replacement_stage_name, stage_index))
        self._choose_stage_popup.increment_stage_index()
    return Status.OK
def _on_choose_stage(self):
    if (not self._choose_stage_popup.isActiveWindow()):
        return Status.OK
    self._choose_stage_popup.close()
    selected_items = self._imported_stages_list.selectedItems()
    for selected_item in selected_items:
        stage_index = self._choose_stage_popup.get_selected_stage_index()
        replacement_stage_name = selected_item.text().split('|')[0][:(- 1)]
        if self._replace_queue:
            stage_indices = list(zip(*self._replace_queue))[1]
            if (stage_index in stage_indices):
                conflict_index = stage_indices.index(stage_index)
                conflict_item = self._replace_queue_list.item(conflict_index)
                self._replace_queue_list.takeItem(self._replace_queue_list.row(conflict_item))
                del self._replace_queue[conflict_index]
            if ((replacement_stage_name, stage_index) in self._replace_queue):
                return Status.OK
        self._choose_stage_popup.set_associated_stage(stage_index, replacement_stage_name)
        item = QListWidgetItem()
        item.setData(self._output_stage_id_key, self._choose_stage_popup.get_stage_id(stage_index))
        item.setData(self._input_filenames_key, selected_item.data(self._input_filenames_key))
        item_text = ((replacement_stage_name + ' -> ') + self._choose_stage_popup.get_stage_name(stage_index))
        item.setText(item_text)
        item.setIcon(QIcon('resources/gray_dot.png'))
        self._replace_queue_list.addItem(item)
        self._replace_queue.append((replacement_stage_name, stage_index))
        self._choose_stage_popup.increment_stage_index()
    return Status.OK