增加了checkbox

This commit is contained in:
sunlit@home 2017-02-03 22:59:42 +08:00
parent 7b96029cfe
commit 3ad2fa5159
2 changed files with 108 additions and 31 deletions

View File

@ -1,31 +1,91 @@
{
"working": false,
"tick":
[
["m1609", "XSPEED"],
["IF1606", "SGIT"],
["IH1606", "SGIT"],
["IH1606", "SGIT"],
["IC1606", "SGIT"],
["IC1606", "SGIT"],
["600036", "LTS", "SZSE"],
["EUR.USD", "IB", "IDEALPRO", "USD", "外汇"]
"working": true,
"tick": [
[
"au1706",
"CTP"
],
[
"a1705",
"CTP"
],
[
"m1705",
"CTP"
],
[
"bu1706",
"CTP"
],
[
"SR705",
"CTP"
],
[
"TA705",
"CTP"
],
[
"MA705",
"CTP"
],
[
"RM705",
"CTP"
],
[
"FG705",
"CTP"
],
[
"OI705",
"CTP"
]
],
"bar":
[
["IF1605", "SGIT"],
["IF1606", "SGIT"],
["IH1606", "SGIT"],
["IH1606", "SGIT"],
["IC1606", "SGIT"],
["IC1606", "SGIT"]
"bar": [
[
"au1706",
"CTP"
],
[
"a1705",
"CTP"
],
[
"m1705",
"CTP"
],
[
"bu1706",
"CTP"
],
[
"SR705",
"CTP"
],
[
"TA705",
"CTP"
],
[
"MA705",
"CTP"
],
[
"RM705",
"CTP"
],
[
"FG705",
"CTP"
],
[
"OI705",
"CTP"
]
],
"active":
{
"IF0000": "IF1605",
"active": {
"IF0000": "IF1605",
"IH0000": "IH1605",
"IC0000": "IC1605"
}

View File

@ -6,6 +6,7 @@ import os
from collections import OrderedDict
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import Qt
from eventEngine import *
from vtFunction import *
@ -53,6 +54,22 @@ class BasicCell(QtGui.QTableWidgetItem):
self.setText(text)
########################################################################
class CheckBoxCell(QtGui.QTableWidgetItem):
"""用来显示复选框的单元格"""
def __init__(self, isChecked=False, mainEngine=None):
"""Constructor"""
super(CheckBoxCell, self).__init__()
self.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
self.setStauts(isChecked)
def setStauts(self, isChecked=False):
if not isChecked:
self.setCheckState(Qt.Unchecked)
else:
self.setCheckState(Qt.Checked)
########################################################################
class NumCell(QtGui.QTableWidgetItem):
"""用来显示数字的单元格"""
@ -1084,9 +1101,9 @@ class ContractMonitor(BasicMonitor):
d['productClass'] = {'chinese':u'合约类型', 'cellType':BasicCell}
d['size'] = {'chinese':u'大小', 'cellType':BasicCell}
d['priceTick'] = {'chinese':u'最小价格变动', 'cellType':BasicCell}
d['tick'] = {'chinese':u'tick', 'cellType':BasicCell}
d['bar'] = {'chinese':u'bar', 'cellType':BasicCell}
d['main'] = {'chinese':u'主力合约', 'cellType':BasicCell}
d['tick'] = {'chinese':u'tick', 'cellType':CheckBoxCell}
d['bar'] = {'chinese':u'bar', 'cellType':CheckBoxCell}
d['main'] = {'chinese':u'主力合约', 'cellType':CheckBoxCell}
#d['strikePrice'] = {'chinese':u'期权行权价', 'cellType':BasicCell}
#d['underlyingSymbol'] = {'chinese':u'期权标的物', 'cellType':BasicCell}
#d['optionType'] = {'chinese':u'期权类型', 'cellType':BasicCell}
@ -1118,10 +1135,10 @@ class ContractMonitor(BasicMonitor):
contract = d[key]
for n, header in enumerate(self.headerList):
if(not hasattr(contract,header)):
break
content = safeUnicode(contract.__getattribute__(header))
cellType = self.headerDict[header]['cellType']
content = None
if (hasattr(contract, header)):
content = safeUnicode(contract.__getattribute__(header))
cell = cellType(content)
if self.font: