/usr/share/pyshared/PyMca/Myqttable.py is in pymca 4.5.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | #/*##########################################################################
# Copyright (C) 2004-2011 European Synchrotron Radiation Facility
#
# This file is part of the PyMCA X-ray Fluorescence Toolkit developed at
# the ESRF by the Beamline Instrumentation Software Support (BLISS) group.
#
# This toolkit is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# PyMCA is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# PyMCA; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA 02111-1307, USA.
#
# PyMCA follows the dual licensing model of Trolltech's Qt and Riverbank's PyQt
# and cannot be used as a free plugin for a non-free program.
#
# Please contact the ESRF industrial unit (industry@esrf.fr) if this license
# is a problem for you.
#############################################################################*/
import qt
import qttable
DEBUG = 0
class QTable(qttable.QTable):
def setItem(self,row,col,item):
try:
qttable.QTable.setItem(self,row,col,item)
except:
self.setCellWidget(row,col,item)
class QTableItem(qttable.QTableItem):
pass
class QTableSelection(qttable.QTableSelection):
pass
class QComboTableItem(qttable.QTableItem):
def __init__(self, table,list):
qttable.QTableItem.__init__(self,table,qttable.QTableItem.Always,"")
self.setReplaceable(0)
self.table=table
self.list=list
self.createEditor()
if len(list):
self.setCurrentItem(self.list[0])
def setCurrentItem(self,cur):
if (type(cur) == type("")) or (type(cur) == type(qt.QString(""))):
if DEBUG:
print("String type %s" % cur)
for i in range (len(self.list)):
if str(cur)==str(self.list[i]):
self.cb.setCurrentItem(i)
return
if DEBUG:
print("string\n %s \nnot in options list" % cur)
else:
if DEBUG:
print("int type")
if cur in range(len(self.list)):
self.cb.setCurrentItem(cur)
def createEditor(self):
self.cb=qt.QComboBox(self.table.viewport())
self.cb.insertStringList(self.list)
self.cb.mySlot = self.mySlot
self.cb.connect(self.cb,qt.SIGNAL("activated(int)"),self.mySlot)
return self.cb
def mySlot (self,index):
if DEBUG:
print("passing mySlot(index), index = %d " % index)
self.table.setText(self.row(),self.col(),self.currentText())
self.table.emit(qt.SIGNAL("valueChanged(int,int)"),(self.row(),self.col()))
def currentItem(self):
return self.cb.currentItem()
def currentText(self):
return self.cb.currentText()
def setStringList(self,slist):
self.list = slist
self.cb.clear()
self.cb.insertStringList(slist)
def setEditable(self,option):
self.cb.setEditable(option)
class QCheckTableItem(qttable.QTableItem):
def __init__(self, table,txt):
qttable.QTableItem.__init__(self,table,qttable.QTableItem.Always,txt)
self.setReplaceable(0)
self.table=table
self.createEditor()
self.setText(txt)
def createEditor(self,text=qt.QString()):
wid = qt.QHBox(self.table.viewport())
self.cb=qt.QCheckBox(wid)
#self.cb.setText(self.f)
self.cb.mySlot = self.mySlot
self.cb.connect(self.cb,qt.SIGNAL("stateChanged(int)"),self.mySlot)
return self.cb
def mySlot (self,value):
if DEBUG:
print("passing mySlot(index), value = ", value)
self.table.emit(qt.SIGNAL("valueChanged(int,int)"),(self.row(),self.col()))
def isChecked(self):
return self.cb.isChecked()
def setChecked(self,value):
return self.cb.setChecked(value)
def setText(self,text):
self.cb.setText(qt.QString(text))
def text(self):
return self.cb.text()
class ColorQTableItem(qttable.QTableItem):
def __init__(self, table, edittype, text,color=qt.Qt.white,bold=None,font=None):
if font is not None:self.setFont(font)
if color is None:color = qt.Qt.white
if bold is None: bold=0
self.color = color
self.bold = bold
qttable.QTableItem.__init__(self, table, edittype, text)
def paint(self, painter, colorgroup, rect, selected):
painter.font().setBold(self.bold)
cg = qt.QColorGroup(colorgroup)
cg.setColor(qt.QColorGroup.Base, self.color)
qttable.QTableItem.paint(self,painter, cg, rect, selected)
painter.font().setBold(0)
|