|
|
|
@ -797,16 +797,28 @@ class MultipleChoiceDialog (QtGui.QWidget):
|
|
|
|
|
super(MultipleChoiceDialog, self).__init__()
|
|
|
|
|
self._parent = parent
|
|
|
|
|
self.layout = QtGui.QGridLayout(self)
|
|
|
|
|
self.layout.setColumnStretch(0,5)
|
|
|
|
|
self.layout.setColumnStretch(1,5)
|
|
|
|
|
self.layout.setColumnStretch(2,0)
|
|
|
|
|
self.layout.setColumnStretch(3,5)
|
|
|
|
|
self.layout.setColumnStretch(4,5)
|
|
|
|
|
|
|
|
|
|
self.Available_dict = Available_dict
|
|
|
|
|
|
|
|
|
|
minimum = QtGui.QSizePolicy.Policy.Maximum
|
|
|
|
|
exp = QtGui.QSizePolicy.Policy.Expanding
|
|
|
|
|
# if there is a possibility of adding
|
|
|
|
|
if add_ability:
|
|
|
|
|
add_line_wgt = QtGui.QWidget(self)
|
|
|
|
|
add_line_layout = QtGui.QHBoxLayout(add_line_wgt)
|
|
|
|
|
# add "input new items" LineEdit
|
|
|
|
|
self.add_LineEdit = QtGui.QLineEdit(self)
|
|
|
|
|
self.layout.addWidget(self.add_LineEdit, 0,0,1,4)
|
|
|
|
|
self.add_LineEdit.setSizePolicy(exp, minimum)
|
|
|
|
|
add_line_layout.addWidget(self.add_LineEdit)
|
|
|
|
|
|
|
|
|
|
# add "add new items" PushButton
|
|
|
|
|
self.add_Button = QtGui.QPushButton(self)
|
|
|
|
|
self.add_Button.setFixedWidth(32)
|
|
|
|
|
try:
|
|
|
|
|
self.add_Button.setIcon(QtGui.QIcon.fromTheme("list-add"))
|
|
|
|
|
except:
|
|
|
|
@ -814,20 +826,27 @@ class MultipleChoiceDialog (QtGui.QWidget):
|
|
|
|
|
self.add_Button.setShortcut \
|
|
|
|
|
(QtGui.QKeySequence(QtCore.Qt.Key_Return))
|
|
|
|
|
self.add_Button.clicked.connect(self.add_new_item)
|
|
|
|
|
self.layout.addWidget(self.add_Button, 0,4)
|
|
|
|
|
|
|
|
|
|
self.add_Button.setSizePolicy(exp, minimum)
|
|
|
|
|
add_line_layout.addWidget(self.add_Button)
|
|
|
|
|
|
|
|
|
|
self.layout.addWidget(add_line_wgt, 0,0,1,5)
|
|
|
|
|
|
|
|
|
|
# add 2 labels
|
|
|
|
|
self.available_label = QtGui.QLabel('Available values', self)
|
|
|
|
|
self.available_label.setSizePolicy(exp, minimum)
|
|
|
|
|
self.layout.addWidget(self.available_label, 1,0,1,2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.selected_label = QtGui.QLabel('Selected values', self)
|
|
|
|
|
self.selected_label.setSizePolicy(exp, minimum)
|
|
|
|
|
self.layout.addWidget(self.selected_label, 1,3,1,2)
|
|
|
|
|
|
|
|
|
|
#add left list
|
|
|
|
|
self.left_ListWidget = ListWidget(self)
|
|
|
|
|
self.left_ListWidget.itemDoubleClicked.connect(self.plus_item)
|
|
|
|
|
self.layout.addWidget(self.left_ListWidget, 2,0,2,2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p_m_wgt = QtGui.QWidget(self)
|
|
|
|
|
p_m_layout = QtGui.QVBoxLayout(p_m_wgt)
|
|
|
|
|
# add '+' button
|
|
|
|
|
self.plus_Button = QtGui.QPushButton(self)
|
|
|
|
|
plus_icons = ['go-next-view','go-next']
|
|
|
|
@ -839,8 +858,8 @@ class MultipleChoiceDialog (QtGui.QWidget):
|
|
|
|
|
if icon_next.isNull():
|
|
|
|
|
self.plus_Button.setText('->')
|
|
|
|
|
self.plus_Button.clicked.connect(self.plus_item)
|
|
|
|
|
self.layout.addWidget(self.plus_Button, 2,2)
|
|
|
|
|
|
|
|
|
|
p_m_layout.addWidget(self.plus_Button)
|
|
|
|
|
|
|
|
|
|
# add '-' button
|
|
|
|
|
self.minus_Button = QtGui.QPushButton(self)
|
|
|
|
|
minus_icons = ['go-previous-view','go-previous']
|
|
|
|
@ -852,55 +871,65 @@ class MultipleChoiceDialog (QtGui.QWidget):
|
|
|
|
|
if icon_prev.isNull():
|
|
|
|
|
self.minus_Button.setText('<-')
|
|
|
|
|
self.minus_Button.clicked.connect(self.minus_item)
|
|
|
|
|
self.layout.addWidget(self.minus_Button, 3,2)
|
|
|
|
|
|
|
|
|
|
p_m_layout.addWidget(self.minus_Button)
|
|
|
|
|
|
|
|
|
|
self.layout.addWidget(p_m_wgt, 2, 2, 2, 1)
|
|
|
|
|
|
|
|
|
|
#add right list
|
|
|
|
|
self.right_ListWidget = ListWidget(self)
|
|
|
|
|
self.right_ListWidget.itemDoubleClicked.connect(self.minus_item)
|
|
|
|
|
self.layout.addWidget(self.right_ListWidget, 2,3,2,2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buttons_wgt = QtGui.QWidget(self)
|
|
|
|
|
buttons_layout = QtGui.QHBoxLayout(buttons_wgt)
|
|
|
|
|
# add OK button
|
|
|
|
|
self.Ok_Button = QtGui.QPushButton('Ok', self)
|
|
|
|
|
self.Ok_Button.clicked.connect(self.ok_pressed)
|
|
|
|
|
self.layout.addWidget(self.Ok_Button, 4,3)
|
|
|
|
|
|
|
|
|
|
self.Ok_Button.setFixedWidth(100)
|
|
|
|
|
buttons_layout.addWidget(self.Ok_Button)
|
|
|
|
|
|
|
|
|
|
# add Cancel button
|
|
|
|
|
self.Cancel_Button = QtGui.QPushButton('Cancel', self)
|
|
|
|
|
self.Cancel_Button = QtGui.QPushButton(_('Cancel'), self)
|
|
|
|
|
self.Cancel_Button.clicked.connect(self.close)
|
|
|
|
|
self.layout.addWidget(self.Cancel_Button, 4,4)
|
|
|
|
|
|
|
|
|
|
self.Cancel_Button.setFixedWidth(100)
|
|
|
|
|
buttons_layout.addWidget(self.Cancel_Button)
|
|
|
|
|
|
|
|
|
|
self.layout.addWidget(buttons_wgt, 4,3,1,2, QtCore.Qt.AlignRight)
|
|
|
|
|
|
|
|
|
|
#add Items in list
|
|
|
|
|
self.left_ListWidget.addItems(
|
|
|
|
|
map(lambda x: Available_dict[x],
|
|
|
|
|
self.left_ListWidget.addItems(map(lambda x: Available_dict[x],
|
|
|
|
|
filter (lambda x: x not in Selected_list,
|
|
|
|
|
Available_list)))
|
|
|
|
|
self.right_ListWidget.addItems(map(lambda x: Available_dict[x],
|
|
|
|
|
filter (lambda x: x in Available_dict.keys(),
|
|
|
|
|
Selected_list)))
|
|
|
|
|
|
|
|
|
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.layout.setRowStretch(0,0)
|
|
|
|
|
self.layout.setRowStretch(1,0)
|
|
|
|
|
self.layout.setRowStretch(2,1)
|
|
|
|
|
self.layout.setRowStretch(3,1)
|
|
|
|
|
self.layout.setRowStretch(4,0)
|
|
|
|
|
self.setLayout(self.layout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_new_item(self):
|
|
|
|
|
# Slot click event add_Button
|
|
|
|
|
if self.add_LineEdit.text() not in [None, '']:
|
|
|
|
|
self.right_ListWidget.addItem(self.add_LineEdit.text())
|
|
|
|
|
self.add_LineEdit.setText('')
|
|
|
|
|
self.add_LineEdit.setFocus()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def plus_item(self):
|
|
|
|
|
# get item in left_ListWidget and set this item in right_ListWidget
|
|
|
|
|
temp_item = self.left_ListWidget.takeItem \
|
|
|
|
|
(self.left_ListWidget.currentRow())
|
|
|
|
|
self.right_ListWidget.addItem(temp_item)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def minus_item(self):
|
|
|
|
|
# get item in right_ListWidget and set this item in left_ListWidget
|
|
|
|
|
temp_item = self.right_ListWidget.takeItem \
|
|
|
|
|
(self.right_ListWidget.currentRow())
|
|
|
|
|
self.left_ListWidget.addItem(temp_item)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ok_pressed(self):
|
|
|
|
|
# save all lists and close this widget
|
|
|
|
|
self._parent.Selected = []
|
|
|
|
|