57 lines
2.1 KiB
Python
57 lines
2.1 KiB
Python
|
from PyQt5.QtWidgets import QWidget, QTreeView, QVBoxLayout
|
||
|
from PyQt5.QtGui import QStandardItemModel, QStandardItem
|
||
|
from typing import List
|
||
|
from parse.ast_load import StoryLine, FragmentSlice, items_map
|
||
|
|
||
|
|
||
|
class CompareWin(QWidget):
|
||
|
def __init__(self):
|
||
|
QWidget.__init__(self)
|
||
|
self.setWindowTitle("故事线比较")
|
||
|
|
||
|
self.__compare_model = QStandardItemModel(self)
|
||
|
self.__compare_view = QTreeView(self)
|
||
|
self.__compare_model.setHorizontalHeaderLabels(["节点名称", "比对参数"])
|
||
|
self.__compare_view.setModel(self.__compare_model)
|
||
|
|
||
|
layout = QVBoxLayout(self)
|
||
|
layout.addWidget(self.__compare_view)
|
||
|
pass
|
||
|
|
||
|
def load_differents(self, changed: List[str], base_list: List[StoryLine], other_list: List[StoryLine]):
|
||
|
base_map = items_map(base_list)
|
||
|
other_map = items_map(other_list)
|
||
|
|
||
|
for changed_item in changed:
|
||
|
item = QStandardItem(changed_item)
|
||
|
item2 = QStandardItem()
|
||
|
item.setEditable(False)
|
||
|
item2.setEditable(False)
|
||
|
self.__compare_model.appendRow([item, item2])
|
||
|
|
||
|
if changed_item in other_map:
|
||
|
story_origin = other_map[changed_item]
|
||
|
item_o = QStandardItem(story_origin.signature)
|
||
|
if not changed_item in base_map:
|
||
|
item2.setText("append")
|
||
|
else:
|
||
|
item2.setText("modify")
|
||
|
item_o2 = QStandardItem(story_origin.file_path)
|
||
|
item_o.setEditable(False)
|
||
|
item_o2.setEditable(False)
|
||
|
item.appendRow([item_o, item_o2])
|
||
|
pass
|
||
|
else:
|
||
|
if changed_item in base_map:
|
||
|
story_modif = base_map[changed_item]
|
||
|
item_ext = QStandardItem(story_modif.signature)
|
||
|
item2.setText("remove")
|
||
|
item_ext2 = QStandardItem(story_modif.file_path)
|
||
|
item_ext.setEditable(False)
|
||
|
item_ext2.setEditable(False)
|
||
|
item.appendRow([item_ext, item_ext2])
|
||
|
pass
|
||
|
pass
|
||
|
pass
|
||
|
pass
|