fix support comments in table

master3.3
Denis Spiridonov 12 years ago
parent 267783e3a3
commit 84d9438b13

@ -1341,12 +1341,6 @@ class MainFrame(QtGui.QWidget):
(table.body.stringArray[row].string[column])
table_widget.setItem(row, col, tablewidgetitem)
# table_widget.item(row, col).setFlags \
# (QtCore.Qt.ItemIsEditable)
# font = table_widget.item(row, col).font()
# font.setWeight(QtGui.QFont.Black)
# table_widget.item(row, col).setFont(font)
elif column > (len(table.values.ChoiceValue) - 1):
for row in range (len(table.body.stringArray)):
tablewidgetitem = QtGui.QTableWidgetItem \
@ -1372,61 +1366,110 @@ class MainFrame(QtGui.QWidget):
tablewidgetitem = QtGui.QTableWidgetItem \
(table.body.stringArray[row].string[column])
table_widget.setItem(row, col, tablewidgetitem)
# if not readonly
elif table.values.ChoiceValue[column].typefield == 'combo':
ChoiceValue = table.values.ChoiceValue[column]
for row in range (len(table.body.stringArray)):
pCombo = QtGui.QComboBox(self)
for i in table.values.ChoiceValue[column].values.string:
pCombo.addItem(i)
if not table.body.stringArray[row].string[column] in\
table.values.ChoiceValue[column].values.string\
and table.body.stringArray[row].string[column]:
pCombo.addItem(table.body.stringArray[row].string[column])
pCombo.setCurrentIndex(len\
(table.values.ChoiceValue \
[column].values.string)+1)
if ChoiceValue.comments and \
hasattr (ChoiceValue.comments, 'string'):
choice = ChoiceValue.comments.string
values = ChoiceValue.values.string
if not table.body.stringArray[row].string[column] \
in ChoiceValue.values.string and \
table.body.stringArray[row].string[column]:
values.append(table.body.stringArray[row].\
string[column])
choice.append(table.body.stringArray[row].\
string[column])
else:
try:
ind = table.values.ChoiceValue[column].values. \
string.index (table.body. \
stringArray[row].string[column])
pCombo.setCurrentIndex(ind)
except:
pCombo.setCurrentIndex(0)
if ChoiceValue.values and \
hasattr (ChoiceValue.values, 'string'):
choice = ChoiceValue.values.string
else:
choice = []
if not table.body.stringArray[row].string[column] in \
choice and table.body. \
stringArray[row].string[column]:
choice.append(table.body.stringArray[row].\
string[column])
values = choice
for ch in range(len(values)):
if len(choice) > ch:
pCombo.addItem(choice[ch])
else:
pCombo.addItem(values[ch])
pCombo.setItemData(ch, values[ch])
try:
ind = values.index (table.body.stringArray[row].\
string[column])
pCombo.setCurrentIndex(ind)
except:
pCombo.setCurrentIndex(0)
if self.expert:
pCombo.currentIndexChanged.connect( \
self.expert_remove(field.name))
self.table_combo_list.append(pCombo)
# OnChange Action
if table.values.ChoiceValue[column].onChanged:
# OnChange Action
if ChoiceValue.onChanged:
self.table_combo_list[len(self.table_combo_list) - 1].\
currentIndexChanged.connect(self.OnChanged\
(row, col, self.table_dict[field.name]))
table_widget.setCellWidget(row, col, \
self.table_combo_list[len(self.table_combo_list)-1])
self.table_combo_list[len(self.table_combo_list)-1])
elif table.values.ChoiceValue[column].typefield == 'comboEdit':
ChoiceValue = table.values.ChoiceValue[column]
for row in range (len(table.body.stringArray)):
pCombo = QtGui.QComboBox(self)
lb = QtGui.QLineEdit(self)
pCombo.setDuplicatesEnabled(False)
pCombo.setEditable(True)
pCombo.setLineEdit(lb)
for i in table.values.ChoiceValue[column].values.string:
pCombo.addItem(i)
if table.body.stringArray[row].string[column] and not \
table.body.stringArray[row].string[column] in\
table.values.ChoiceValue[column].values.string:
pCombo.addItem(table.body.stringArray[row].string[column])
ind = pCombo.findText(table.body. \
stringArray[row].string[column])
if ind == -1:
ind = 0
pCombo.setCurrentIndex(ind)
if ChoiceValue.comments and \
hasattr (ChoiceValue.comments, 'string'):
choice = ChoiceValue.comments.string
values = ChoiceValue.values.string
if not table.body.stringArray[row].string[column] \
in ChoiceValue.values.string and \
table.body.stringArray[row].string[column]:
values.append(table.body.stringArray[row].\
string[column])
choice.append(table.body.stringArray[row].\
string[column])
else:
if ChoiceValue.values and \
hasattr (ChoiceValue.values, 'string'):
choice = ChoiceValue.values.string
else:
choice = []
if not table.body.stringArray[row].string[column] in \
choice and table.body. \
stringArray[row].string[column]:
choice.append(table.body.stringArray[row].\
string[column])
values = choice
for ch in range(len(values)):
if len(choice) > ch:
pCombo.addItem(choice[ch])
else:
pCombo.addItem(values[ch])
pCombo.setItemData(ch, values[ch])
try:
ind = values.index (table.body.stringArray[row].\
string[column])
pCombo.setCurrentIndex(ind)
except:
pCombo.setCurrentIndex(0)
if self.expert:
pCombo.currentIndexChanged.connect( \
self.expert_remove(field.name))
@ -1439,31 +1482,29 @@ class MainFrame(QtGui.QWidget):
elif table.values.ChoiceValue[column].typefield in \
['multichoice', 'multichoice_add']:
ChoiceValue = table.values.ChoiceValue[column]
for row in range (len(table.body.stringArray)):
if table.values.ChoiceValue[column].typefield == \
'multichoice_add':
if ChoiceValue.typefield == 'multichoice_add':
add_ability = True
else:
add_ability = False
choice = table.values.ChoiceValue[column].values.string
choice = ChoiceValue.values.string
default = table.body.stringArray[row].string[column].\
split(',')
if table.values.ChoiceValue[column].comments:
comments = table.values.ChoiceValue[column].comments.\
string
if ChoiceValue.comments:
comments = ChoiceValue.comments
else:
comments = []
self.multi_obj = MultipleChoice(self, choice, default, \
comments, add_ability, False)
comments, add_ability, False)
if self.expert:
self.multi_obj.Changed.connect( \
self.expert_remove(field.name))
self.table_multi_list.append(self.multi_obj)
table_widget.setCellWidget(row, col, \
self.table_multi_list[len(self.table_multi_list)-1])
self.table_multi_list[len(self.table_multi_list)-1])
elif table.values.ChoiceValue[column].typefield in \
['check', 'check_tristate']:
@ -1617,14 +1658,9 @@ class MainFrame(QtGui.QWidget):
[self.method_name]['steps_field'].help
self.group_name_label = LabelWordWrap(group_name, self)
# self.group_name_label.setAlignment(QtCore.Qt.AlignCenter)
self.group_name_label.setStyleSheet(
"font-size: 16px; color: #000;"
"font: bold;"
# "font-size: 24px; color: #fff;"
# "border-bottom: 2px black;"
# "border-radius: 8px;"
# "background-color: #777;"
)
@ -1642,14 +1678,8 @@ class MainFrame(QtGui.QWidget):
for Group in GroupField:
if Group.name:
self.group_name_label = LabelWordWrap(Group.name, self)
# self.group_name_label.setAlignment(QtCore.Qt.AlignCenter)
self.group_name_label.setStyleSheet(
"font-size: 16px; color: #000;"
"font: bold;")
# "font-size: 24px; color: #fff;"
# "border-bottom: 2px black;"
# "border-radius: 8px;"
# "background-color: #777;");
self.group_name_label.setStyleSheet("font-size: 16px;"
"color: #000; font: bold;")
self.brief_grid.addWidget(self.group_name_label, x, y, 1, 2)
x += 1
@ -1675,16 +1705,12 @@ class MainFrame(QtGui.QWidget):
self.grid.addWidget(brief_sa, x, y, 1, 2)
x += 1
# x = self._parent.control_button.add_standart_button \
# (self, GroupField[-1], x, y, brief = True,\
# next_button_text = next_button_text)
self.add_standart_button.connect(self._parent.control_button.\
add_standart_button)
self.add_standart_button.emit(GroupField[-1], x, y, True, \
next_button_text)
next_button_text)
# add spacer
self.spacer_item = QtGui.QSpacerItem( 0, 0, \
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding )
@ -1695,13 +1721,13 @@ class MainFrame(QtGui.QWidget):
self._parent.control_button.show()
self._parent.control_button.setMethodName \
(self.ClientObj.view_method_name)
# self.grid.setContentsMargins(10,10,10,0)
self.grid.setContentsMargins(24,28,10,0)
self.update()
self.ClientObj.app.processEvents()
self.updateGeometry()
def show_brief_widget(self, brief_widget, expert_brief):
def wrapper():
if brief_widget.isVisible():
@ -1713,7 +1739,7 @@ class MainFrame(QtGui.QWidget):
self.grid.removeItem(self.spacer_item)
expert_brief.set_open()
return wrapper
def print_brief_group(self, Fields, x):
y = 0
for field in Fields:
@ -1775,7 +1801,7 @@ class MainFrame(QtGui.QWidget):
self.view_dict[field.name].disabled = True
x += 2
self.view_dict.pop(field.name)
elif field.element == 'table' and field.type != 'steps':
field.type = None
field.default = False
@ -1784,7 +1810,6 @@ class MainFrame(QtGui.QWidget):
if field.type == 'writable':
x += 1
self.view_dict.pop(field.name)
return x
def expert_remove(self, field_name):
@ -1958,8 +1983,10 @@ class MainFrame(QtGui.QWidget):
if self.view_dict[field.name].cellWidget(i,j):
if type(self.view_dict[field.name].cellWidget(i,j)) == \
QtGui.QComboBox:
ind = self.view_dict[field.name].cellWidget(i,j).\
currentIndex()
text = self.view_dict[field.name].cellWidget(i,j).\
currentText()
itemData(ind)
elif type(self.view_dict[field.name].cellWidget(i,j)) == \
MultipleChoice:
list_result = self.view_dict[field.name].\

Loading…
Cancel
Save