-
Notifications
You must be signed in to change notification settings - Fork 11
/
DiffWidget.py
145 lines (121 loc) · 5.35 KB
/
DiffWidget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#-*- codingg:utf8 -*-
from PyQt5.QtWidgets import QWidget, QTabWidget, QHBoxLayout,QVBoxLayout,QListWidget,QSplitter,QListWidgetItem
from PyQt5.QtCore import Qt,QSize,QSettings
from PyQt5.QtGui import QColor
import sys
class CellDiffWidget(QWidget):
def __init__(self):
super(CellDiffWidget,self).__init__()
self.CellDiffListWidget = QListWidget()
self.MergeAddDiffListWidget = QListWidget()
self.MergeDelDiffListWidget = QListWidget()
self.MainLayout = QHBoxLayout()
self.CellTabWidget = QTabWidget()
self.CellTabWidget.addTab(self.CellDiffListWidget,"单元格改动")
self.CellTabWidget.addTab(self.MergeAddDiffListWidget,"合并区域增加")
self.CellTabWidget.addTab(self.MergeDelDiffListWidget,"合并区域删除")
self.MainLayout.addWidget(self.CellTabWidget)
self.setLayout(self.MainLayout)
def sizeHint(self):
return QSize(200,300)
def clear(self):
self.CellDiffListWidget.clear()
self.MergeAddDiffListWidget.clear()
self.MergeDelDiffListWidget.clear()
def setData(self,data):
self.clear()
self.ColorSettings = QSettings("ExcelDiffer", "Color");
add = self.ColorSettings.value("add");
delcolor = self.ColorSettings.value("delcolor");
change = self.ColorSettings.value("change");
for nm in data["new_merge"]:
a = QListWidgetItem("新增区域 -> "+str(nm))
a.setForeground(QColor(add))
self.MergeAddDiffListWidget.addItem(a)
for nm in data["del_merge"]:
a = QListWidgetItem("删除区域 -> "+str(nm))
a.setForeground(QColor(delcolor))
self.MergeDelDiffListWidget.addItem(a)
for diff in data["change_cell"]:
a = QListWidgetItem(str(diff[0]) + " -- " + str(diff[2][0]) +"\n" + str(diff[1]) + " -- " + str(diff[2][1]))
a.setForeground(QColor(change))
self.CellDiffListWidget.addItem(a)
class RowDiffWidget(QWidget):
def __init__(self):
super(RowDiffWidget,self).__init__()
self.RowDelListWidget = QListWidget()
self.RowAddListWidget = QListWidget()
self.RowExcListWidget = QListWidget()
self.MainLayout = QHBoxLayout()
self.RowTabWidget = QTabWidget()
self.RowTabWidget.addTab(self.RowAddListWidget,"行增加")
self.RowTabWidget.addTab(self.RowDelListWidget,"行删除")
self.RowTabWidget.addTab(self.RowExcListWidget,"行交换")
self.MainLayout.addWidget(self.RowTabWidget)
self.setLayout(self.MainLayout)
def sizeHint(self):
return QSize(200,300)
def clear(self):
self.RowDelListWidget.clear()
self.RowAddListWidget.clear()
self.RowExcListWidget.clear()
def setData(self,data):
self.clear()
self.ColorSettings = QSettings("ExcelDiffer", "Color");
add = self.ColorSettings.value("add");
delcolor = self.ColorSettings.value("delcolor");
change = self.ColorSettings.value("change");
for row in data["add_row"]:
a = QListWidgetItem("新增行 -> "+str(row))
a.setForeground(QColor(add))
self.RowAddListWidget.addItem(a)
for row in data["del_row"]:
a = QListWidgetItem("删除行 -> "+str(row))
a.setForeground(QColor(delcolor))
self.RowDelListWidget.addItem(a)
for row in data["row_exchange"]:
a = QListWidgetItem("交换行 -> "+str(row[0]) +" -- " +str(row[1]))
a.setForeground(QColor(change))
self.RowExcListWidget.addItem(a)
class ColDiffWidget(QWidget):
def __init__(self):
super(ColDiffWidget,self).__init__()
self.ColDelListWidget = QListWidget()
self.ColAddListWidget = QListWidget()
self.ColExcListWidget = QListWidget()
self.MainLayout = QHBoxLayout()
self.ColTabWidget = QTabWidget()
self.ColTabWidget.addTab(self.ColAddListWidget,"列增加")
self.ColTabWidget.addTab(self.ColDelListWidget,"列删除")
self.ColTabWidget.addTab(self.ColExcListWidget,"列交换")
self.MainLayout.addWidget(self.ColTabWidget)
self.setLayout(self.MainLayout)
def sizeHint(self):
return QSize(200,300)
def clear(self):
self.ColDelListWidget.clear()
self.ColAddListWidget.clear()
self.ColExcListWidget.clear()
def setData(self,data):
self.clear()
self.ColorSettings = QSettings("ExcelDiffer", "Color");
add = self.ColorSettings.value("add");
delcolor = self.ColorSettings.value("delcolor");
change = self.ColorSettings.value("change");
for col in data["add_col"]:
a = QListWidgetItem("新增列 -> "+str(col))
a.setForeground(QColor(add))
self.ColAddListWidget.addItem(a)
for col in data["del_col"]:
a = QListWidgetItem("删除列 -> "+str(col))
a.setForeground(QColor(delcolor))
self.ColDelListWidget.addItem(a)
for col in data["col_exchange"]:
a = QListWidgetItem("交换列 -> "+str(col[0])+" -- "+str(col[1]))
a.setForeground(QColor(change))
self.ColExcListWidget.addItem(a)
if __name__=="__main__":
app = QApplication(sys.argv)
main = RowDiffWidget()
main.show()
sys.exit(app.exec_())