def populateVars(self, selectedVar=None): selected = None self.ui.varTableWidget.clear() self.ui.varTableWidget.setSortingEnabled(False) self.ui.varTableWidget.setRowCount(len(self.__vars)) headers = ["Name", "Value", "Info"] self.ui.varTableWidget.setColumnCount(len(headers)) self.ui.varTableWidget.setHorizontalHeaderLabels(headers) for row, name in enumerate(sorted(self.__vars.keys())): item = QTableWidgetItem(name) item.setData(Qt.UserRole, QVariant(name)) flags = item.flags() flags ^= Qt.ItemIsEditable item.setFlags(flags) self.ui.varTableWidget.setItem(row, 0, item) item2 = QTableWidgetItem(self.__vars[name] or "") self.ui.varTableWidget.setItem(row, 1, item2) item3 = QTableWidgetItem(self.__pardesc[name]['doc'] or "") flags = item3.flags() flags &= ~Qt.ItemIsEnabled item3.setFlags(flags) self.ui.varTableWidget.setItem(row, 2, item3) if selectedVar is not None and selectedVar == name: selected = item2 self.ui.varTableWidget.setSortingEnabled(True) self.ui.varTableWidget.resizeColumnsToContents() self.ui.varTableWidget.horizontalHeader()\ .setStretchLastSection(True) if selected is not None: selected.setSelected(True) self.ui.varTableWidget.setCurrentItem(selected)
def get_columns_names(self): """ A function that retrieves the name of the columns from the .csv file and returns a list with name :return: """ self.IHD.TWColumnNames.clear() with open(self.input_file) as f: read_all = f.readlines() first_row_bo = True if not self.rb_pressed: c = read_all[0].count(",") sc = read_all[0].count(";") if c > sc: self.sep = "," else: self.sep = ";" for row in read_all: row = row.split(self.sep) if first_row_bo: first_row = row first_row_bo = False else: second_row = row break headingrow = [] for col in first_row: only_char = check_text(col) headingrow.append(only_char) self.col_types = self.determine_coloumn_type() combo_box_options = ["Integer", "Decimal value", "Character"] self.combo = [] self.IHD.TWColumnNames.setRowCount(len(headingrow)) self.IHD.TWColumnNames.setColumnCount(3) self.IHD.TWColumnNames.setSelectionBehavior( QAbstractItemView.SelectRows) for i, col in enumerate(headingrow): item1 = QTableWidgetItem(col) item1.setFlags(xor(item1.flags(), QtCore.Qt.ItemIsEditable)) item2 = QTableWidgetItem(second_row[i]) item2.setFlags(xor(item2.flags(), QtCore.Qt.ItemIsEditable)) self.combo.append(RadioComboBox()) for nr, t in enumerate(combo_box_options): self.combo[i].addItem(t) item = self.combo[i].model().item(nr, 0) if self.col_types[i] == nr: item.setCheckState(QtCore.Qt.Checked) self.combo[i].setCurrentIndex(nr) else: item.setCheckState(QtCore.Qt.Unchecked) self.IHD.TWColumnNames.setItem(i, 0, item1) self.IHD.TWColumnNames.setItem(i, 1, item2) self.IHD.TWColumnNames.setCellWidget(i, 2, self.combo[i]) self.combo[i].view().pressed.connect(self.change_col_type) first_row_checked = [] for name in first_row: first_row_checked.append(check_text(name)) self.IHD.ComBHarvestCol.addItems(first_row_checked) self.heading_row = first_row_checked self.IHD.pButInsertDataIntoDB.setEnabled(True)
def populateFieldTable(self): if self.collectedDataDict: importingFields = self.collectedDataDict[0].keys() self.fieldTable.clear() self.fieldTable.setRowCount(len(importingFields)) predefinedFields = ['EOMETRY','ODKUUID'] for row,field in enumerate(importingFields): enabledItem = QTableWidgetItem() enabledItem.setFlags(enabledItem.flags() | Qt.ItemIsUserCheckable) enabledItem.setText("") self.fieldTable.setItem(row,0,enabledItem) ODKfieldItem = QTableWidgetItem() ODKfieldItem.setText(field) self.fieldTable.setItem(row,1,ODKfieldItem) self.fieldTable.setRowHeight(row,30) QGISfieldItem = QTableWidgetItem() if slugify(field) in self.fieldMapping: QGISfieldItem.setText(self.fieldMapping[slugify(field)]) enabledItem.setCheckState(Qt.Checked) else: QGISfieldItem.setText("") enabledItem.setCheckState(Qt.Unchecked) self.fieldTable.setItem(row,2,QGISfieldItem) if field[-7:] in predefinedFields: #prevent predefined fields user editing if field[-7:] == 'ODKUUID': ODKfieldItem.setText('ODKUUID') enabledItem.setCheckState(Qt.Checked) enabledItem.setFlags(enabledItem.flags() & Qt.ItemIsEditable) ODKfieldItem.setFlags(ODKfieldItem.flags() & Qt.ItemIsEditable) QGISfieldItem.setFlags(QGISfieldItem.flags() & Qt.ItemIsEditable)
def addRow(self): index = self.daily_plan_table.rowCount() self.daily_plan_table.insertRow(index) box_l = sorted([box.name for box in runner.models.Box.objects.all()]) mouse_l = sorted([mouse.name for mouse in runner.models.Mouse.objects.all()]) board_l = sorted([board.name for board in runner.models.Board.objects.all()]) # Box, combo box qcb = create_combo_box(box_l) self.daily_plan_table.setCellWidget(index, 2, qcb) self.daily_plan_table.setItem(index, 2, QTableWidgetItem('')) # Board, combo box qcb = create_combo_box(board_l) self.daily_plan_table.setCellWidget(index, 3, qcb) self.daily_plan_table.setItem(index, 3, QTableWidgetItem('')) # Previous pipe, read only text = '' item = QTableWidgetItem(text) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(index, 4, item) # Previous perf, read only text = '' item = QTableWidgetItem(text) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(index, 5, item) # Start, button qb = QPushButton('Start') #~ qb.setCheckable(True) qb.clicked.connect(functools.partial(self.start_session2, qb)) self.daily_plan_table.setCellWidget(index, 6, qb) # New perf, read only item = QTableWidgetItem('-') item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(index, 7, item) # New pipe, text box item = QTableWidgetItem('-') self.daily_plan_table.setItem(index, 8, item) item = QTableWidgetItem('') self.daily_plan_table.setItem(index, 9, item) # Remove, button rmvButton = QPushButton('Remove') self.daily_plan_table.setCellWidget(index, 10, rmvButton) self.daily_plan_table.setItem(index, 10, QTableWidgetItem('')) #Necessary to keep track of changing index persindex = QPersistentModelIndex(self.daily_plan_table.model().index(index, 10)) rmvButton.clicked.connect(functools.partial(self.removeRow, persindex))
def get_columns_names(self): """A function that retrieves the name of the columns from the .csv file and returns a list with name""" self.ISD.TWColumnNames.clear() shp_file = shp.Reader(self.file_name_with_path + '.shp') f_row = True try: if len(shp_file.shapes()[0].points) > 1: self.isPolyon = True else: self.isPolyon = False except: QMessageBox.information(None, self.tr("Error:"), self.tr('No shapes was found in the file')) _types = [] for name, type_, length, precision in shp_file.fields: if f_row: f_row = False continue self.col_names.append(name) _types.append(type_) if type_ == 'N': self.col_types.append(0) if type_ == 'F': self.col_types.append(1) if type_ == 'C': self.col_types.append(2) second_row = shp_file.iterRecords().next() combo_box_options = ["Integer", "Decimal value", "Character"] self.ISD.TWColumnNames.setRowCount(len(self.col_names)) self.ISD.TWColumnNames.setColumnCount(3) self.ISD.TWColumnNames.setSelectionBehavior( QAbstractItemView.SelectRows) for i, row in enumerate(self.col_names): item1 = QTableWidgetItem(row) item1.setFlags(xor(item1.flags(), QtCore.Qt.ItemIsEditable)) item2 = QTableWidgetItem(str(second_row[i])) item2.setFlags(xor(item2.flags(), QtCore.Qt.ItemIsEditable)) self.combo.append(RadioComboBox()) for nr, t in enumerate(combo_box_options): self.combo[i].addItem(t) item = self.combo[i].model().item(nr, 0) if self.col_types[i] == nr: item.setCheckState(QtCore.Qt.Checked) self.combo[i].setCurrentIndex(nr) else: item.setCheckState(QtCore.Qt.Unchecked) self.ISD.TWColumnNames.setItem(i, 0, item1) self.ISD.TWColumnNames.setItem(i, 1, item2) self.ISD.TWColumnNames.setCellWidget(i, 2, self.combo[i]) self.add_to_DB_row_count = i
def populateFieldTable(self): if self.collectedDataDict: importingFields = self.collectedDataDict[0].keys() self.fieldTable.clear() self.fieldTable.setRowCount(len(importingFields)) predefinedFields = ['EOMETRY','UUID'] for row,field in enumerate(importingFields): enabledItem = QTableWidgetItem() enabledItem.setFlags(enabledItem.flags() | Qt.ItemIsUserCheckable) enabledItem.setText("") self.fieldTable.setItem(row,0,enabledItem) ODKfieldItem = QTableWidgetItem() ODKfieldItem.setText(field) self.fieldTable.setItem(row,1,ODKfieldItem) self.fieldTable.setRowHeight(row,30) QGISfieldItem = QTableWidgetItem() # try to guess field mapping QGISfieldItem.setText("") enabledItem.setCheckState(Qt.Unchecked) for fieldOrigin, FieldDest in self.fieldMapping.iteritems(): if fieldOrigin in slugify(field): QGISfieldItem.setText(FieldDest) enabledItem.setCheckState(Qt.Checked) break ''' if slugify(field) in self.fieldMapping: QGISfieldItem.setText(self.fieldMapping[slugify(field)]) enabledItem.setCheckState(Qt.Checked) else: QGISfieldItem.setText("") enabledItem.setCheckState(Qt.Unchecked) ''' self.fieldTable.setItem(row,2,QGISfieldItem) for predef in predefinedFields: if predef in field.upper(): #prevent predefined fields user editing if predef == 'UUID': ODKfieldItem.setText(field) QGISfieldItem.setText('ODKUUID') elif predef == 'EOMETRY': ODKfieldItem.setText('GEOMETRY') QGISfieldItem.setText('GEOMETRY') enabledItem.setCheckState(Qt.Checked) enabledItem.setFlags(enabledItem.flags() & Qt.ItemIsEditable) ODKfieldItem.setFlags(ODKfieldItem.flags() & Qt.ItemIsEditable) QGISfieldItem.setFlags(QGISfieldItem.flags() & Qt.ItemIsEditable)
def __init__(self, parent = None, datalist = None, mode='r'): super(SimpleListDlg, self).__init__(parent) self.tbl = QTableWidget() self.mode = mode # read only or write 'r'/'w' self.values = [] if datalist is not None: data = datalist.toList() self.tbl.setRowCount(len(data)) self.tbl.setColumnCount(1) for i,val in enumerate(data): #print i, val.toFloat() self.values.append(val.toFloat()[0]) it = QTableWidgetItem("%g" % val.toFloat()[0]) if self.mode == 'r': it.setFlags(it.flags() & ~Qt.ItemIsEditable) self.tbl.setItem(i,0,it) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) layout = QVBoxLayout() layout.addWidget(self.tbl) layout.addWidget(buttonBox) self.setLayout(layout) self.connect(buttonBox, SIGNAL("accepted()"), self.accept) self.connect(buttonBox, SIGNAL("rejected()"), self.reject)
def _add_task_to_table(self, row, task): self._ignore_cell_changed = True self.setItem(row, self._dict_header['id'], QTableWidgetItem(str(task.identifier))) self.item(row, self._dict_header['id']) \ .setTextAlignment(Qt.AlignCenter) self.setItem(row, self._dict_header['name'], QTableWidgetItem(str(task.name))) combo = QComboBox() items = [task_type for task_type in Task.task_types_names] combo.addItems(items) # FIXME: only until I get an access to the documentation. for i, t in enumerate(Task.task_types_names): if t == task.task_type: combo.setCurrentIndex(i) combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['task_type'])) self.setCellWidget(row, self._dict_header['task_type'], combo) item = QTableWidgetItem(task.abort_on_miss and 'Yes' or 'No') item.setFlags( Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) item.setCheckState(task.abort_on_miss and Qt.Checked or Qt.Unchecked) self.setItem(row, self._dict_header['abort'], item) self.setItem(row, self._dict_header['list_activation_dates'], QTableWidgetItem( ', '.join(map(str, task.list_activation_dates)))) self.item(row, self._dict_header['list_activation_dates']) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) for i in ['activation_date', 'period', 'deadline', 'wcet', 'base_cpi', 'n_instr', 'mix', 'acet', 'et_stddev', 'preemption_cost']: self.setItem(row, self._dict_header[i], QTableWidgetItem(str(task.__dict__[i]))) self.item(row, self._dict_header[i]) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) stack_item = QTableWidgetItem(str(task.stack_file)) stack_item.setFlags(stack_item.flags() ^ (Qt.ItemIsEditable)) self.setItem(row, self._dict_header['sdp'], stack_item) combo = QComboBox() combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['followed'])) self.setCellWidget(row, self._dict_header['followed'], combo) for col in range(len(self._custom_fields)): key = self._custom_fields[col] if key in task.data and task.data[key] is not None: item = QTableWidgetItem(str(task.data[key])) else: item = QTableWidgetItem('') item.setBackgroundColor(QColor.fromRgb(200, 255, 200)) self.setItem(row, col + len(self._header), item) self._ignore_cell_changed = False self._show_period(task, row)
def __init__(self, parent, caller): super(aggregate, self).__init__(parent) self.parent = parent self.iface = caller.iface self.resize(QSize(310, 260)) self.setColumnCount(2) self.setColumnWidth(0, 152) self.setColumnWidth(1, 152) self.setRowCount(len(self.parameters) - 1) self.verticalHeader().hide() self.horizontalHeader().hide() S = QSettings() for row, parameter in enumerate(self.parameters): if row == 0: self.service_id = parameter[1] continue row = row - 1 pKey = QTableWidgetItem(parameter[0]) pKey.setFlags(pKey.flags() ^ Qt.ItemIsEditable) pValue = QTableWidgetItem(parameter[1]) self.setItem(row, 0, pKey) valueFromSettings = S.value( "QRealTime/%s/%s/" % (self.service_id, self.item(row, 0).text()), defaultValue="undef") if not valueFromSettings or valueFromSettings == "undef": self.setItem(row, 1, pValue) S.setValue( "QRealTime/%s/%s/" % (self.service_id, self.item(row, 0).text()), parameter[1]) else: self.setItem(row, 1, QTableWidgetItem(valueFromSettings))
def _add_proc_to_table(self, row, proc_info): self.setItem(row, 0, QTableWidgetItem(str(proc_info.identifier))) self.item(row, 0).setTextAlignment(Qt.AlignCenter) self.setItem(row, 1, QTableWidgetItem(str(proc_info.name))) self.setItem(row, 2, QTableWidgetItem(str(proc_info.cs_overhead))) self.item(row, 2).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self.setItem(row, 3, QTableWidgetItem(str(proc_info.cl_overhead))) self.item(row, 3).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self.setItem( row, 4, QTableWidgetItem(', '.join([x.name for x in proc_info.caches]))) penalty_item = QTableWidgetItem(str(proc_info.penalty)) penalty_item.setFlags(penalty_item.flags() ^ (Qt.ItemIsEditable | Qt.ItemIsEnabled)) self.setItem(row, 5, penalty_item) self.item(row, 5).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self.setItem(row, 6, QTableWidgetItem(str(proc_info.speed))) for col in range(len(self._custom_fields)): key = self._custom_fields[col] if key in proc_info.data and proc_info.data[key] is not None: item = QTableWidgetItem(str(proc_info.data[key])) else: item = QTableWidgetItem('') item.setBackgroundColor(QColor.fromRgb(200, 255, 200)) self.setItem(row, col + len(self._header), item)
def list_assignments(self): try: r = self.service.get_assignment_list() except Exception as e: return self.exception_sb(e) self.ui.table_assignments.setRowCount(len(r)) self.assignment_list = r for i in range(len(r)): item = QTableWidgetItem(r[i][1]) item.setFlags(item.flags() & ~ QtCore.Qt.ItemIsEditable) self.ui.table_assignments.setItem(i, 0, item) item = QTableWidgetItem(r[i][2]) item.setFlags(item.flags() & ~ QtCore.Qt.ItemIsEditable) self.ui.table_assignments.setItem(i, 1, item)
def __init__(self, parent=None, datalist=None, mode='r'): super(SimpleListDlg, self).__init__(parent) self.tbl = QTableWidget() self.mode = mode # read only or write 'r'/'w' self.values = [] if datalist is not None: data = datalist.toList() self.tbl.setRowCount(len(data)) self.tbl.setColumnCount(1) for i, val in enumerate(data): #print i, val.toFloat() self.values.append(val.toFloat()[0]) it = QTableWidgetItem("%g" % val.toFloat()[0]) if self.mode == 'r': it.setFlags(it.flags() & ~Qt.ItemIsEditable) self.tbl.setItem(i, 0, it) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) layout = QVBoxLayout() layout.addWidget(self.tbl) layout.addWidget(buttonBox) self.setLayout(layout) self.connect(buttonBox, SIGNAL("accepted()"), self.accept) self.connect(buttonBox, SIGNAL("rejected()"), self.reject)
def _add_proc_to_table(self, row, proc_info): self.setItem(row, 0, QTableWidgetItem(str(proc_info.identifier))) self.item(row, 0).setTextAlignment(Qt.AlignCenter) self.setItem(row, 1, QTableWidgetItem(str(proc_info.name))) self.setItem(row, 2, QTableWidgetItem(str(proc_info.cs_overhead))) self.item(row, 2).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self.setItem(row, 3, QTableWidgetItem(str(proc_info.cl_overhead))) self.item(row, 3).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self.setItem( row, 4, QTableWidgetItem(', '.join([x.name for x in proc_info.caches]))) penalty_item = QTableWidgetItem(str(proc_info.penalty)) penalty_item.setFlags(penalty_item.flags() ^ (Qt.ItemIsEditable | Qt.ItemIsEnabled)) self.setItem(row, 5, penalty_item) self.item(row, 5).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self.setItem(row, 6, QTableWidgetItem(str(proc_info.speed))) for col in range(len(self._custom_fields)): key = self._custom_fields[col] if key in proc_info.data and proc_info.data[key] is not None: item = QTableWidgetItem(str(proc_info.data[key])) else: item = QTableWidgetItem('') item.setBackgroundColor(QColor.fromRgb(200, 255, 200)) self.setItem(row, col + len(self._header), item)
def _add_task_to_table(self, row, task): self._ignore_cell_changed = True self.setItem(row, self._dict_header['id'], QTableWidgetItem(str(task.identifier))) self.item(row, self._dict_header['id']) \ .setTextAlignment(Qt.AlignCenter) self.setItem(row, self._dict_header['name'], QTableWidgetItem(str(task.name))) combo = QComboBox() items = [task_type for task_type in Task.task_types_names] combo.addItems(items) combo.setCurrentIndex(combo.findText(task.task_type)) combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['task_type'])) self.setCellWidget(row, self._dict_header['task_type'], combo) item = QTableWidgetItem(task.abort_on_miss and 'Yes' or 'No') item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled | Qt.ItemIsSelectable) item.setCheckState(task.abort_on_miss and Qt.Checked or Qt.Unchecked) self.setItem(row, self._dict_header['abort'], item) self.setItem( row, self._dict_header['list_activation_dates'], QTableWidgetItem(', '.join(map(str, task.list_activation_dates)))) self.item(row, self._dict_header['list_activation_dates']) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) for i in [ 'activation_date', 'period', 'deadline', 'wcet', 'base_cpi', 'n_instr', 'mix', 'acet', 'et_stddev', 'preemption_cost' ]: self.setItem(row, self._dict_header[i], QTableWidgetItem(str(task.__dict__[i]))) self.item(row, self._dict_header[i]) \ .setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) stack_item = QTableWidgetItem(str(task.stack_file)) stack_item.setFlags(stack_item.flags() ^ (Qt.ItemIsEditable)) self.setItem(row, self._dict_header['sdp'], stack_item) combo = QComboBox() combo.currentIndexChanged.connect( lambda x: self._cell_changed(row, self._dict_header['followed'])) self.setCellWidget(row, self._dict_header['followed'], combo) for col in range(len(self._custom_fields)): key = self._custom_fields[col] if key in task.data and task.data[key] is not None: item = QTableWidgetItem(str(task.data[key])) else: item = QTableWidgetItem('') item.setBackgroundColor(QColor.fromRgb(200, 255, 200)) self.setItem(row, col + len(self._header), item) self._ignore_cell_changed = False self._show_period(task, row)
def metaStateChanged(self, newState, oldState): if newState == Phonon.ErrorState: QMessageBox.warning(self.__main_window, "Error opening files", self.__meta_information_resolver.errorString()) while self.__list_music and self.__list_music.pop( ) != self.__meta_information_resolver.currentSource(): pass return if newState != Phonon.StoppedState and newState != Phonon.PausedState: return if self.__meta_information_resolver.currentSource().type( ) == Phonon.MediaSource.Invalid: return metaData = self.__meta_information_resolver.metaData() title = metaData.get(QString('TITLE'), [''])[0] if not title: title = self.__meta_information_resolver.currentSource().fileName() artist = metaData.get(QString('ARTIST'), [''])[0] if artist: title = title + ' - ' + artist titleItem = QTableWidgetItem(title) titleItem.setFlags(titleItem.flags() ^ Qt.ItemIsEditable) titleItem.setTextAlignment(Qt.AlignLeft | Qt.AlignVCenter) long_duration = self.__meta_information_resolver.totalTime() total_time_item = QTableWidgetItem( QTime(0, (long_duration / 60000) % 60, (long_duration / 1000) % 60).toString('mm:ss')) total_time_item.setFlags(total_time_item.flags() ^ Qt.ItemIsEditable) total_time_item.setTextAlignment(Qt.AlignHCenter | Qt.AlignVCenter) currentRow = self.__music_table.rowCount() self.__music_table.insertRow(currentRow) self.__music_table.setItem(currentRow, 0, titleItem) self.__music_table.setItem(currentRow, 1, total_time_item) if not self.__music_table.selectedItems(): self.__music_table.selectRow(0) self.__media_object.setCurrentSource( self.__meta_information_resolver.currentSource()) index = self.__list_music.index( self.__meta_information_resolver.currentSource()) + 1 if len(self.__list_music) > index: self.__meta_information_resolver.setCurrentSource( self.__list_music[index])
def get_columns_names(self): """A function that retrieves the name of the columns from the .csv file and returns a list with name""" self.ITD.TWColumnNames.clear() with open(self.file_name_with_path) as f: read_all = f.readlines() first_row = True for row in read_all: row = re.split((self.sep + ' |' + self.sep), row) if first_row: heading_row = row first_row = False else: second_row = row break self.col_types = self.determine_column_type() combo_box_options = ["Integer", "Decimal value", "Character"] self.combo = [] self.ITD.TWColumnNames.setRowCount(len(heading_row)) self.ITD.TWColumnNames.setColumnCount(3) self.ITD.TWColumnNames.setSelectionBehavior( QAbstractItemView.SelectRows) for i, row in enumerate(heading_row): item1 = QTableWidgetItem(row) item1.setFlags(xor(item1.flags(), QtCore.Qt.ItemIsEditable)) item2 = QTableWidgetItem(second_row[i]) item2.setFlags(xor(item2.flags(), QtCore.Qt.ItemIsEditable)) self.combo.append(RadioComboBox()) for nr, t in enumerate(combo_box_options): self.combo[i].addItem(t) item = self.combo[i].model().item(nr, 0) if self.col_types[i] == nr: item.setCheckState(QtCore.Qt.Checked) self.combo[i].setCurrentIndex(nr) else: item.setCheckState(QtCore.Qt.Unchecked) self.ITD.TWColumnNames.setItem(i, 0, item1) self.ITD.TWColumnNames.setItem(i, 1, item2) self.ITD.TWColumnNames.setCellWidget(i, 2, self.combo[i]) self.combo[i].view().pressed.connect(self.change_col_type) self.add_to_DB_row_count = i
def fill_first_tlb(self): self.IDB.TWTableNames.setRowCount(len(self.tbl_names)) self.IDB.TWTableNames.setColumnCount(1) self.IDB.TWTableNames.setSelectionBehavior( QAbstractItemView.SelectRows) for i, row in enumerate(self.tbl_names): item1 = QTableWidgetItem(row) item1.setFlags(xor(item1.flags(), Qt.ItemIsEditable)) self.IDB.TWTableNames.setItem(i, 0, item1) #self.combo[i].view().pressed.connect(self.change_col_type) self.IDB.TWTableNames.itemDoubleClicked.connect( self._change_example) self.add_to_DB_row_count = i
def reset_table(self, table, digital=1): """Set empty table items in all of the cells of the given table. The items are not editable. digital -- 1: Set the background colour red -- 0: Set the text as ''.""" for i in range(table.rowCount()): for j in range(table.columnCount()): item = QTableWidgetItem() item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(i, j, item) if digital: table.item(i, j).setBackground(Qt.red) else: table.item(i, j).setText('')
def _add_cache_to_table(self, row, cache): self._ignore_cell_changed = True self.setItem(row, 0, QTableWidgetItem(str(cache.identifier))) self.item(row, 0).setTextAlignment(Qt.AlignCenter) self.setItem(row, 1, QTableWidgetItem(str(cache.name))) self.setItem(row, 2, QTableWidgetItem(str(cache.size))) self.item(row, 2).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self.setItem(row, 3, QTableWidgetItem(str(cache.access_time))) self.item(row, 3).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) penalty_item = QTableWidgetItem(str(cache.penalty)) penalty_item.setFlags(penalty_item.flags() ^ (Qt.ItemIsEditable | Qt.ItemIsEnabled)) self.setItem(row, 4, penalty_item) self.item(row, 4).setTextAlignment(Qt.AlignRight | Qt.AlignVCenter) self._ignore_cell_changed = False
def initGradTable(self): table = self.dlg.sediGradTable if self.gradClass: table.setRowCount(2) table.setColumnCount(len(self.gradClass)) for j in range(0, len(self.gradClass)): minSize, maxSize, portion = self.gradClass[j] item = QTableWidgetItem(str(minSize) + ' - ' + str(maxSize)) item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, j, item) table.setItem(1, j, QTableWidgetItem()) table.item(1, j).setText(str(portion)) self.showContent()
def _populate_hostinfo_table(self): self._hostinfo_table.setVisible( self._server_info is not None ) if not self._server_info: return for column_index, fieldname in enumerate(SERVER_INFO_FIELDS): try: field = self._server_info[fieldname] except KeyError: field = "<UNDEFINED>" item = QTableWidgetItem(field) flags = item.flags() flags &= ~Qt.ItemIsSelectable flags &= ~Qt.ItemIsEditable item.setFlags( flags ) self._hostinfo_table.setItem(0, column_index, item) self._hostinfo_table.resizeColumnsToContents() self._hostinfo_table.horizontalHeader().setStretchLastSection(True) # Force refresh of last column.
def refresh_table(self): self._manual_change = True self._custom_fields = list(self._configuration.scheduler_info.data.keys()) labels = self._header + self._custom_fields self.setRowCount(len(labels)) self.setVerticalHeaderLabels(labels) self.horizontalHeader().setStretchLastSection(False) header = self.horizontalHeader() header.setResizeMode(0, QHeaderView.Stretch) header.setResizeMode(1, QHeaderView.Interactive) self.horizontalHeader().hide() scheduler_item = QTableWidgetItem( self._configuration.scheduler_info.name) scheduler_item.setFlags(scheduler_item.flags() ^ (Qt.ItemIsEditable)) self.setItem(0, 0, scheduler_item) self.btn_edit = QPushButton(self) self.btn_edit.setText('Edit') self.btn_edit.clicked.connect(self._simulation_tab.openEditor) self.btn_edit.setEnabled(bool(self._configuration.scheduler_info.name)) self.setCellWidget(0, 1, self.btn_edit) self.setItem( 1, 0, QTableWidgetItem(str( self._configuration.scheduler_info.overhead)) ) self.setSpan(1, 0, 1, 2) self.setItem( 2, 0, QTableWidgetItem(str( self._configuration.scheduler_info.overhead_activate)) ) self.setSpan(2, 0, 1, 2) self.setItem( 3, 0, QTableWidgetItem(str( self._configuration.scheduler_info.overhead_terminate)) ) self.setSpan(3, 0, 1, 2) i = 4 for name, value in self._configuration.scheduler_info.data.items(): self.setItem(i, 0, QTableWidgetItem(str(value))) self.setSpan(i, 0, 1, 2) i += 1
def addCorrector(self, idx): if not self._corlst1.selectedItems(): return #print self._corlst1.itemFromIndex(idx).text(0) nrow = self.table4.rowCount() if nrow >= self._nmax: QtGui.QMessageBox.critical( self, "Local Orbit Bump", "ERROR: We need only {0} correctors.".format(self._nmax), QtGui.QMessageBox.Ok) #self.progress.setValue(0) return self.table4.setRowCount(nrow+1) it0 = self._corlst1.selectedItems()[-1] icor, ok = it0.data(0, Qt.UserRole).toInt() if icor < 0: return newc = self._cors[icor] for j in range(self.table4.columnCount()): it = QTableWidgetItem() if j > 0: it.setTextAlignment( Qt.AlignRight | Qt.AlignVCenter) header = self.table4.horizontalHeaderItem(j) if header.text() != "dBump": it.setFlags(it.flags() & (~Qt.ItemIsEditable)) else: it.setData(Qt.DisplayRole, "0") it.setData(Qt.UserRole, 0.0) self.table4.setItem(nrow, j, it) self.table4.item(nrow,0).setData(Qt.UserRole, icor) for j,h in [(0, "Element"), (1, "s [m]")]: self.table4.item(nrow,j).setData(Qt.DisplayRole, it0.text(self._header[h])) for j in range(self._corlst1.columnCount()): it0.setForeground(j, Qt.red) it0.setDisabled(True) self.emit(SIGNAL("correctorAdded(PyQt_PyObject)"), newc) # use initial values self.updateTwiss() self.updateCorReadings() self.table4.resizeColumnsToContents() if self.table4.rowCount() == self._nmax: #print "All correctors are ready" self.emit(SIGNAL("correctorsComplete()"))
def addCorrector(self, idx): if not self._corlst1.selectedItems(): return #print self._corlst1.itemFromIndex(idx).text(0) nrow = self.table4.rowCount() if nrow >= self._nmax: QtGui.QMessageBox.critical( self, "Local Orbit Bump", "ERROR: We need only {0} correctors.".format(self._nmax), QtGui.QMessageBox.Ok) #self.progress.setValue(0) return self.table4.setRowCount(nrow+1) it0 = self._corlst1.selectedItems()[-1] icor, ok = it0.data(0, Qt.UserRole).toInt() if icor < 0: return newc = self._cors[icor] for j in range(self.table4.columnCount()): it = QTableWidgetItem() if j > 0: it.setTextAlignment( Qt.AlignRight | Qt.AlignVCenter) header = self.table4.horizontalHeaderItem(j) if header.text() != "dBump": it.setFlags(it.flags() & (~Qt.ItemIsEditable)) else: it.setData(Qt.DisplayRole, "0") it.setData(Qt.UserRole, 0.0) self.table4.setItem(nrow, j, it) self.table4.item(nrow,0).setData(Qt.UserRole, icor) for j,h in [(0, "Element"), (1, "s [m]")]: self.table4.item(nrow,j).setData(Qt.DisplayRole, it0.text(self._header[h])) for j in range(self._corlst1.columnCount()): it0.setForeground(j, Qt.red) it0.setDisabled(True) self.emit(SIGNAL("correctorAdded(PyQt_PyObject)"), newc) # use initial values self.updateTwiss() self.updateCorReadings() self.table4.resizeColumnsToContents() if self.table4.rowCount() == self._nmax: #print "All correctors are ready" self.emit(SIGNAL("correctorsComplete()"))
def _populate_hostinfo_table(self): self._hostinfo_table.setVisible(self._server_info is not None) if not self._server_info: return for column_index, fieldname in enumerate(SERVER_INFO_FIELDS): try: field = self._server_info[fieldname] except KeyError: field = "<UNDEFINED>" item = QTableWidgetItem(field) flags = item.flags() flags &= ~Qt.ItemIsSelectable flags &= ~Qt.ItemIsEditable item.setFlags(flags) self._hostinfo_table.setItem(0, column_index, item) self._hostinfo_table.resizeColumnsToContents() self._hostinfo_table.horizontalHeader().setStretchLastSection( True) # Force refresh of last column.
def populate_function_table_1(self): """Populate the tblFunctions1 table with available functions.""" hazards = deepcopy(hazard_all) exposures = exposure_all self.lblAvailableFunctions1.clear() self.tblFunctions1.clear() self.tblFunctions1.setColumnCount(len(hazards)) self.tblFunctions1.setRowCount(len(exposures)) for i in range(len(hazards)): hazard = hazards[i] item = QTableWidgetItem() item.setIcon(QIcon(get_image_path(hazard))) item.setText(hazard['name'].capitalize()) item.setTextAlignment(Qt.AlignLeft) self.tblFunctions1.setHorizontalHeaderItem(i, item) for i in range(len(exposures)): exposure = exposures[i] item = QTableWidgetItem() item.setIcon(QIcon(get_image_path(exposure))) item.setText(exposure['name'].capitalize()) self.tblFunctions1.setVerticalHeaderItem(i, item) developer_mode = setting('developer_mode', False, bool) for hazard in hazards: for exposure in exposures: item = QTableWidgetItem() if (exposure in hazard['disabled_exposures'] and not developer_mode): background_colour = unavailable_option_color # Set it disable and un-selectable item.setFlags(item.flags() & ~Qt.ItemIsEnabled & ~Qt.ItemIsSelectable) else: background_colour = available_option_color item.setBackground(QBrush(background_colour)) item.setFont(big_font) item.setTextAlignment(Qt.AlignCenter | Qt.AlignHCenter) item.setData(RoleHazard, hazard) item.setData(RoleExposure, exposure) self.tblFunctions1.setItem(exposures.index(exposure), hazards.index(hazard), item) self.parent.pbnNext.setEnabled(False)
def __init__(self, parent=None): model = SensitivityStudyParametersModel() parameters = model.getParameters() n_parameters = len(parameters) super(QTableWidget, self).__init__(n_parameters, len(self.columns), parent) self.verticalHeader().setResizeMode(QHeaderView.Fixed) self.verticalHeader().hide() headers = [self.columns[col_id].header for col_id in self.column_list] self.setHorizontalHeaderLabels(headers) for row in range(n_parameters): param_name = parameters[row] param_name_widget = QLabel(param_name) param_name_widget.setMargin(5) self.setCellWidget(row, self.columns["name"].index, param_name_widget) if (model.getParameterType(param_name) == ErtImplType.GEN_KW): const_value_model = SensivityStudyParametersConstantValueModel(param_name, model) const_value_widget = StringBox(const_value_model, "Constant value", "config/simulation/sensitivity_parameter_constant_value") const_value_widget.setValidator(FloatArgument()) const_value_widget.setAlignment(Qt.AlignRight) self.setCellWidget(row, self.columns["const_value"].index, const_value_widget) else: empty_item = QTableWidgetItem() empty_item.setFlags(empty_item.flags() ^ Qt.ItemIsEditable) self.setItem(row, self.columns["const_value"].index, empty_item) is_active_model = SensivityStudyParametersIsIncludedModel(param_name, model) is_active_widget = CheckBox(is_active_model, "Is included", "config/simulation/sensitivity_parameter_is_included", show_label=False) self.setCellWidget(row, self.columns["is_active"].index, is_active_widget) self.resizeColumnsToContents() self.setMinimumWidth(self.sizeHint().width()) self.blockSignals(False)
def modelChanged(self): """Retrieves data from the model and inserts it into the table.""" values = self.model.getDictionary() blocked = self.table.blockSignals(True) for row in reversed(range(self.table.rowCount())): self.table.removeRow(row) row = 0 for key in values: key_item = QTableWidgetItem(str(key)) key_item.setFlags(key_item.flags() ^ Qt.ItemIsEditable) value_item = QTableWidgetItem(str(values[key])) self.table.insertRow(row) self.table.setItem(row, 0, key_item) self.table.setItem(row, 1, value_item) row += 1 self.table.blockSignals(blocked)
def add_to_param_list(self): """Adds the selected columns to the list of fields that should be treated as "special" in the database both to work as a parameter that could be evaluated and as a layer that is added to the canvas""" row_count = self.add_to_param_row_count self.ISD.TWtoParam.setColumnCount(1) items_to_add = [] existing_values = [] if row_count != 0: for i in range(row_count): existing_values.append(self.ISD.TWtoParam.item(i, 0).text()) for item in self.ISD.TWColumnNames.selectedItems(): if item.column() == 0 and item.text() not in existing_values: items_to_add.append(item.text()) for i, item in enumerate(items_to_add, self.add_to_param_row_count): row_count += 1 self.ISD.TWtoParam.setRowCount(row_count) item1 = QTableWidgetItem(item) item1.setFlags(xor(item1.flags(), QtCore.Qt.ItemIsEditable)) self.ISD.TWtoParam.setItem(i, 0, item1) self.add_to_param_row_count = row_count self.ISD.pButContinue.setEnabled(True)
def _appendRecord(self, name): vec = name.split('.') if len(vec) > 2: QMessageBox.critical(None, "ERROR", "format is wrong") return if len(vec) == 1: elem, field = vec[0], 'value' elif len(vec) == 2: elem, field = vec elemobj = hla.getElements(elem) if elemobj: # pvsrb is a list pvsrb = elemobj.pv(field=field, handle='readback') self.pvs_rb.append(pvsrb) pvssp = elemobj.pv(field=field, handle='setpoint') self.pvs_sp.append(pvssp) else: QMessageBox.critical(None, "ERROR", "element %s not found" % elem) return # expand one row m, n = self.table.rowCount(), self.table.columnCount() self.table.insertRow(m) # add cells item = QTableWidgetItem(elem) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_ELEMENT, item) item = QTableWidgetItem(field) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_FIELD, item) item = QTableWidgetItem(', '.join(pvsrb)) #item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) self.table.setItem(m, self.COL_PV, item) readval = ['%.4e' % v for v in caget(pvsrb)] item = QTableWidgetItem(', '.join(readval)) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_READBACK, item) # set the stepsize of PV stepsize = 0.00001 if pvssp: item = QTableWidgetItem('%f' % stepsize) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_STEPSIZE, item) self.spinbox.append(QDoubleSpinBox(self.table)) self.spinbox[-1].setRange(-100, 100) #self.spinbox[-1].setValue(float(10.0)) self.spinbox[-1].setSingleStep(stepsize) self.spinbox[-1].setDecimals(10) self.spinbox[-1].valueChanged.connect(self._writePv) self.table.setCellWidget(m, self.COL_SETPOINT, self.spinbox[-1]) sp = float(caget(pvssp)[0]) #print "setpoint:", pvssp, sp, type(sp) self.spinbox[-1].setValue(-1e-5) #print "connected", self.spinbox[-1].value() else: item = self.table.item(m, self.COL_STEPSIZE) if item: item.setFlags(item.flags() & (~Qt.ItemIsEditable)) item = self.table.item(m, self.COL_SETPOINT) if item: item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.spinbox.append(None) self.table.resizeColumnsToContents()
def __init__(self, bpms, cors, parent = None): super(OrbitCorrGeneral, self).__init__(parent) self.bpms, self.cors = bpms, cors self.sb = [bpm.sb for bpm in self.bpms] self.x0, self.y0 = None, None self._update_current_orbit() self.table = QTableWidget(len(self.bpms), 9) self.table.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) hdview = QHeaderView(Qt.Horizontal) self.table.setHorizontalHeaderLabels( ['BPM Name', 's', "Beta X", "Beta Y", "Eta X", 'X Bump', 'Y Bump', "Target X", "Target Y"]) self._twiss = getTwiss([b.name for b in self.bpms], ["s", "betax", "betay", "etax"]) for i,bpm in enumerate(self.bpms): it = QTableWidgetItem(bpm.name) it.setFlags(it.flags() & (~Qt.ItemIsEditable)) self.table.setItem(i, 0, it) it = QTableWidgetItem(str(bpm.sb)) it.setFlags(it.flags() & (~Qt.ItemIsEditable)) #it.setMinimumWidth(80) self.table.setItem(i, 1, it) self.table.setItem(i, 2, QTableWidgetItem("%.4f" % self._twiss[i,1])) self.table.setItem(i, 3, QTableWidgetItem("%.4f" % self._twiss[i,2])) self.table.setItem(i, 4, QTableWidgetItem("%.4f" % self._twiss[i,3])) for j in range(5, 9): it = QTableWidgetItem(str(0.0)) it.setData(Qt.DisplayRole, str(0.0)) it.setFlags(it.flags() | Qt.ItemIsEditable) self.table.setItem(i, j, it) # use the current orbit #self.table.item(i,4).setData(Qt.DisplayRole, str(self.x0[i])) #self.table.item(i,5).setData(Qt.DisplayRole, str(self.y0[i])) #self.connect(self.table, SIGNAL("cellClicked(int, int)"), # self._cell_clicked) self.table.resizeColumnsToContents() #self.table.horizontalHeader().setStretchLastSection(True) #for i in range(4): # print "width", i, self.table.columnWidth(i) #self.table.setColumnWidth(0, 300) self.table.setColumnWidth(1, 80) vbox1 = QtGui.QVBoxLayout() frmbox = QFormLayout() self.base_orbit_box = QtGui.QComboBox() #self.base_orbit_box.addItems([ # "Current Orbit", "All Zeros"]) self.base_orbit_box.addItems(["All Zeros", "Current Orbit"]) frmbox.addRow("Orbit Base", self.base_orbit_box) grp = QtGui.QGroupBox("Local Bump") grp.setLayout(frmbox) vbox1.addWidget(grp) frmbox = QFormLayout() hln1 = QtGui.QFrame() hln1.setLineWidth(3) hln1.setFrameStyle(QtGui.QFrame.Sunken) hln1.setFrameShape(QtGui.QFrame.HLine) frmbox.addRow(hln1) self.repeatbox = QSpinBox() self.repeatbox.setRange(1, 20) self.repeatbox.setValue(3) # or connect the returnPressed() signal frmbox.addRow("&Repeat correction", self.repeatbox) self.rcondbox = QLineEdit() self.rcondbox.setValidator(QDoubleValidator(0, 1, 0, self)) self.rcondbox.setText("1e-2") frmbox.addRow("r&cond for SVD", self.rcondbox) self.scalebox = QDoubleSpinBox() self.scalebox.setRange(0.01, 5.00) self.scalebox.setSingleStep(0.01) self.scalebox.setValue(0.68) frmbox.addRow("&Scale correctors", self.scalebox) #hln2 = QtGui.QFrame() #hln2.setLineWidth(3) #hln2.setFrameStyle(QtGui.QFrame.Sunken) #hln2.setFrameShape(QtGui.QFrame.HLine) #frmbox.addRow(hln2) self.progress = QProgressBar() self.progress.setMaximum(self.repeatbox.value()) self.progress.setMaximumHeight(15) frmbox.addRow("Progress", self.progress) grp = QtGui.QGroupBox("Correction") grp.setLayout(frmbox) vbox1.addWidget(grp) #vbox.addStretch(1.0) #self.qdb = QDialogButtonBox(self) #self.qdb.addButton("APP", QDialogButtonBox.ApplyRole) #self.qdb.addButton("R", QDialogButtonBox.ResetRole) #btn.setDefault(True) #self.qdb.addButton(QDialogButtonBox.Cancel) #self.qdb.addButton(QDialogButtonBox.Help) gbox = QtGui.QGridLayout() btn = QPushButton("Clear") self.connect(btn, SIGNAL("clicked()"), self.resetBumps) gbox.addWidget(btn, 0, 1) self.correctOrbitBtn = QPushButton("Apply") #self.correctOrbitBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.correctOrbitBtn.setStyleSheet("QPushButton:disabled { color: gray }"); self.connect(self.correctOrbitBtn, SIGNAL("clicked()"), self.call_apply) self.correctOrbitBtn.setDefault(True) gbox.addWidget(self.correctOrbitBtn, 1, 1) gbox.setColumnStretch(0, 1) vbox1.addStretch() vbox1.addLayout(gbox) hbox1 = QtGui.QHBoxLayout() hbox1.addWidget(self.table, 2) hbox1.addLayout(vbox1, 0) self.setLayout(hbox1) self.connect(self.base_orbit_box, SIGNAL("currentIndexChanged(QString)"), self.updateTargetOrbit) self.connect(self.repeatbox, SIGNAL("valueChanged(int)"), self.progress.setMaximum) self.connect(self.table, SIGNAL("cellChanged (int, int)"), self.updateBump)
def setSnapshotTable(self, data, table, eventid): if data: length = len(data.values()[0]) else: print ('data is empty, exit.') return for i in range(1, len(data.values())): if length != len(data.values()[i]): QMessageBox.warning(self, "Warning", "Data length are not consistent.") return if isinstance(data, odict) and isinstance(table, QTableWidget): table.setSortingEnabled(False) table.clear() nrows = len(data.values()[0]) # ('pv name label', 'dbr_type label', 'string value', 'int value', 'double value', 'status label', 'severity label', # 'ioc time stamp label', 'ioc time stamp nano label', 'is_array', 'array_value'), # => (pv_name, status, severity, ioc_timestamp, saved value) # ncols = len(data) - 6 # ncols = ncols + 3 # 2 columns for live data and (live data - saved data), selected restore pv ncols = len(data) - 3 table.setRowCount(nrows) table.setColumnCount(ncols) pvnames = data['PV Name'] status = data['Status'] severity = data['Severity'] ts = data['Time stamp'] ts_nano = data['Time stamp (nano)'] dbrtype = data['DBR'] s_value = data['S_value'] i_value = data['I_value'] d_value = data['D_value'] isConnected = data['isConnected'] is_array = data['isArray'] array_value = data['arrayValue'] keys = ['Name', 'Status', 'Severity', 'Time Stamp', 'Connection', 'Saved Value', 'Live Value', 'Delta', 'Not Restore'] table.setHorizontalHeaderLabels(keys) for i in range(nrows): item = table.item(i, 8) if item: item.setCheckState(False) else: item = QTableWidgetItem() item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsUserCheckable) table.setItem(i, 8, item) item.setCheckState(False) if pvnames[i]: self.__setTableItem(table, i, 0, pvnames[i]) if status[i]: self.__setTableItem(table, i, 1, str(status[i])) if severity[i]: self.__setTableItem(table, i, 2, str(severity[i])) if ts[i]: dt = str(datetime.datetime.fromtimestamp(ts[i]+ts_nano[i]*1.0e-9)) self.__setTableItem(table, i, 3, dt) if is_array[i]: self.__setTableItem(table, i, 5, self.__arrayTextFormat(array_value[i])) self.arrayData[pvnames[i]+'_'+str(eventid)] = array_value[i] else: if dbrtype[i] in self.epicsDouble: self.__setTableItem(table, i, 5, str(d_value[i])) elif dbrtype[i] in self.epicsLong: self.__setTableItem(table, i, 5, str(i_value[i])) elif dbrtype[i] in self.epicsString: self.__setTableItem(table, i, 5, str(s_value[i])) elif dbrtype[i] in self.epicsNoAccess: # channel are not connected. pass else: print('invalid dbr type (code = %s)'%(dbrtype[i])) if isConnected[i]: self.__setTableItem(table, i, 4, str(bool(isConnected[i]))) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) else: self.__setTableItem(table, i, 4, 'False') item.setCheckState(True) item.setSelected(True) # disable user checkable function item.setFlags(item.flags() ^ Qt.ItemIsUserCheckable) for item_idx in range(9): itemtmp = table.item(i, item_idx) if not itemtmp: itemtmp = QTableWidgetItem() table.setItem(i, item_idx, itemtmp) itemtmp.setBackground(self.brushbadpv) table.setSortingEnabled(True) else: raise "Either given data is not an instance of OrderedDict or table is not an instance of QtGui.QTableWidget"
def _appendRecord(self, name): vec = name.split('.') if len(vec) > 2: QMessageBox.critical(None, "ERROR", "format is wrong") return if len(vec) == 1: elem, field = vec[0], 'value' elif len(vec) == 2: elem, field = vec elemobj = hla.getElements(elem) if elemobj: # pvsrb is a list pvsrb = elemobj.pv(field=field, handle='readback') self.pvs_rb.append(pvsrb) pvssp = elemobj.pv(field=field, handle='setpoint') self.pvs_sp.append(pvssp) else: QMessageBox.critical(None, "ERROR", "element %s not found" % elem) return # expand one row m, n = self.table.rowCount(), self.table.columnCount() self.table.insertRow(m) # add cells item = QTableWidgetItem(elem) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_ELEMENT, item) item = QTableWidgetItem(field) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_FIELD, item) item = QTableWidgetItem(', '.join(pvsrb)) #item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) self.table.setItem(m, self.COL_PV, item) readval = ['%.4e' % v for v in caget(pvsrb)] item = QTableWidgetItem(', '.join(readval)) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_READBACK, item) # set the stepsize of PV stepsize = 0.00001 if pvssp: item = QTableWidgetItem('%f' % stepsize) item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.table.setItem(m, self.COL_STEPSIZE, item) self.spinbox.append(QDoubleSpinBox(self.table)) self.spinbox[-1].setRange(-100, 100) #self.spinbox[-1].setValue(float(10.0)) self.spinbox[-1].setSingleStep(stepsize) self.spinbox[-1].setDecimals(10) self.spinbox[-1].valueChanged.connect(self._writePv) self.table.setCellWidget(m, self.COL_SETPOINT, self.spinbox[-1]) sp = float(caget(pvssp)[0]) #print "setpoint:", pvssp, sp, type(sp) self.spinbox[-1].setValue(-1e-5) #print "connected", self.spinbox[-1].value() else: item = self.table.item(m, self.COL_STEPSIZE) if item: item.setFlags(item.flags() & (~Qt.ItemIsEditable)) item = self.table.item(m, self.COL_SETPOINT) if item: item.setFlags(item.flags() & (~Qt.ItemIsEditable)) self.spinbox.append(None) self.table.resizeColumnsToContents()
def addLayer(self, layer, headers, types, features): tab = QtGui.QWidget() tab.layer = layer p1_vertical = QtGui.QVBoxLayout(tab) p1_vertical.setContentsMargins(0,0,0,0) table = QtGui.QTableWidget(); self.connect(table, SIGNAL("itemSelectionChanged()"), self.selectionChanged) table.title = layer.name() table.crs = layer.crs() table.setColumnCount(len(headers)) if len(features) > 0: table.setRowCount(len(features)) nbrow = len(features) self.loadingWindow.show() self.loadingWindow.setLabelText(table.title) self.loadingWindow.activateWindow(); self.loadingWindow.showNormal(); # Table population m = 0 for feature in features: n = 0 for cell in feature.attributes(): item = QTableWidgetItem() item.setData(Qt.DisplayRole, cell) item.setFlags(item.flags() ^ Qt.ItemIsEditable) item.feature = feature table.setItem(m, n, item) n += 1 m += 1 self.loadingWindow.setValue(int((float(m)/nbrow)*100)) QApplication.processEvents() else: table.setRowCount(0) table.setHorizontalHeaderLabels(headers) table.horizontalHeader().setMovable(True) table.types = types table.filter_op = [] table.filters = [] for i in range(0, len(headers)): table.filters.append('') table.filter_op.append(0) header = table.horizontalHeader() header.setContextMenuPolicy(Qt.CustomContextMenu) header.customContextMenuRequested.connect(partial(self.filterMenu, table)) table.setSortingEnabled(True) p1_vertical.addWidget(table) # Status bar to display informations (ie: area) tab.sb = QtGui.QStatusBar() p1_vertical.addWidget(tab.sb) title = table.title # We reduce the title's length to 20 characters if len(title)>20: title = title[:20]+'...' # We add the number of elements to the tab's title. title += ' ('+str(len(features))+')' self.tabWidget.addTab(tab, title) # Add the tab to the conatiner self.tabWidget.setTabToolTip(self.tabWidget.indexOf(tab), table.title) # Display a tooltip with the layer's full name
def refresh_table(self): self._manual_change = True self._custom_fields = list( self._configuration.scheduler_info.data.keys()) labels = self._header + self._custom_fields self.setRowCount(len(labels)) self.setVerticalHeaderLabels(labels) self.horizontalHeader().setStretchLastSection(False) header = self.horizontalHeader() header.setResizeMode(0, QHeaderView.Stretch) header.setResizeMode(1, QHeaderView.Interactive) #header.setResizeMode(2, QHeaderView.Interactive) self.horizontalHeader().hide() combo = QComboBox() combo.addItems(['Custom scheduler...'] + list(get_schedulers())) self.setCellWidget(0, 0, combo) self.setSpan(0, 0, 1, 2) name = self._configuration.scheduler_info.filename scheduler_item = QTableWidgetItem( name and os.path.relpath(name, self._configuration.cur_dir)) scheduler_item.setFlags(scheduler_item.flags() ^ (Qt.ItemIsEditable)) self.setItem(1, 0, scheduler_item) self._btn_open = QPushButton(self) self._btn_open.setText('Open') self._btn_open.clicked.connect(self._open_scheduler) self.setCellWidget(1, 1, self._btn_open) combo.currentIndexChanged['QString'].connect(self._select_scheduler) if self._configuration.scheduler_info.clas: i = combo.findText(self._configuration.scheduler_info.clas) if i <= 0: i = 0 combo.setCurrentIndex(i) self.setItem( 2, 0, QTableWidgetItem(str(self._configuration.scheduler_info.overhead))) self.setSpan(2, 0, 1, 2) self.setItem( 3, 0, QTableWidgetItem( str(self._configuration.scheduler_info.overhead_activate))) self.setSpan(3, 0, 1, 2) self.setItem( 4, 0, QTableWidgetItem( str(self._configuration.scheduler_info.overhead_terminate))) self.setSpan(4, 0, 1, 2) i = 5 for name, value in self._configuration.scheduler_info.data.items(): self.setItem(i, 0, QTableWidgetItem(str(value))) self.setSpan(i, 0, 1, 2) i += 1 combo.setCurrentIndex(combo.findText('simso.schedulers.RM_mono'))
def set_table_data(self): # Date of most recent session # Hack because the datetimes are coming back as aware but in UTC? # Are they being stored incorrectly in UTC? # Or is django just not retrieving them in the current timezone? target_date = runner.models.Session.objects.order_by( '-date_time_start')[0].date_time_start.astimezone(tz).date() self.target_date_display.setText(target_date.strftime('%Y-%m-%d')) # Only include sessions from at least this recent # This should be longer than the max vacation time recency_cutoff = target_date - datetime.timedelta(days=21) # Get all mice that are in training mice_qs = runner.models.Mouse.objects.filter(in_training=True) # Get previous session from each mouse previous_sessions = [] previous_sessions_sort_keys = [] new_mice = [] for mouse in mice_qs.all(): # Find previous sessions from this mouse from all boxes, # sorted by date and excluding ancient ones mouse_prev_sess_qs = runner.models.Session.objects.filter( mouse=mouse, date_time_start__date__gte=recency_cutoff, ).order_by('date_time_start') # Store the most recent, or if None, add to new_mice if mouse_prev_sess_qs.count() > 0: # The most recent sess = mouse_prev_sess_qs.last() # Skip if the last session was not in LOCALE_BOXES, that is, # if it was trained on some other setup if sess.box.name not in LOCALE_BOXES: continue # Store sess previous_sessions.append(sess) # Store these sort keys to enable sorting # Index into LOCALE_BOXES previous_sessions_board_idx = LOCALE_BOXES.index(sess.box.name) # date time start dtstart = sess.date_time_start # sort keys previous_sessions_sort_keys.append( (previous_sessions_board_idx, dtstart)) else: new_mice.append(mouse) # Incantantion to sort previous_sessions by sort keys previous_sessions = [ x for junk, x in sorted( zip(previous_sessions_sort_keys, previous_sessions)) ] # Get the choices for box and board box_l = LOCALE_BOXES board_l = sorted(runner.models.Board.objects.all().values_list( 'name', flat=True)) # Get box arduinos and cameras for polling self.relevant_box_names = [] self.relevant_box_arduinos = [] self.relevant_box_cameras = [] for box_name in box_l: box = runner.models.Box.objects.filter(name=box_name).first() self.relevant_box_names.append(box_name) self.relevant_box_arduinos.append(box.serial_port) self.relevant_box_cameras.append(box.video_device) # Set every row with the same widgets # 0 - Mouse, read only # 1 - Weight, text box # 2 - Box, combo box # 3 - Board, combo box # 4 - Previous pipe, read only # 5 - Previous perf, read only # 6 - Start, button # 7 - Performance, read only # 8 - Pipe stop, read only self.daily_plan_table.setRowCount(len(previous_sessions)) for nrow, session in enumerate(previous_sessions): # Set the row height self.daily_plan_table.setRowHeight(nrow, ROW_HEIGHT) # Mouse name, read only item = QTableWidgetItem(session.mouse.name) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 0, item) # Weight, text box item = QTableWidgetItem(str(session.user_data_weight)) self.daily_plan_table.setItem(nrow, 1, item) # Box, combo box qcb = create_combo_box(box_l, choice=session.box.name) self.daily_plan_table.setCellWidget(nrow, 2, qcb) # Board, combo box qcb = create_combo_box(board_l, choice=session.board.name) self.daily_plan_table.setCellWidget(nrow, 3, qcb) # Previous pipe, read only try: text = '%0.2f' % session.user_data_water_pipe_position_stop except TypeError: text = '' item = QTableWidgetItem(text) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 4, item) # Previous perf, read only try: text = '%0.f; %0.f' % ( 100 * session.user_data_left_perf, 100 * session.user_data_right_perf, ) except TypeError: text = '' item = QTableWidgetItem(text) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 5, item) # Start, button qb = QPushButton('Start') #~ qb.setCheckable(True) qb.clicked.connect(functools.partial(self.start_session2, qb)) self.daily_plan_table.setCellWidget(nrow, 6, qb) # New perf, read only item = QTableWidgetItem('-') item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 7, item) # New pipe, text box item = QTableWidgetItem('-') self.daily_plan_table.setItem(nrow, 8, item)
def showPropOnTable(self, bankSecData, Type='Move'): if Type == 'Fixed': self.dlg.noMoveRdo.setChecked(True) else: self.dlg.retreatRdo.setChecked(True) table = self.dlg.sectionPropTable table.clear() n_layers = len(bankSecData.layerItems) table.setRowCount(2 * n_layers + 2) layerData = bankSecData.layerItems[0] if len(bankSecData.gradList) > 8: table.setColumnCount(len(layerData.gradList)) else: table.setColumnCount(8) table.setRowHeight(0, 60) item = QTableWidgetItem('MinElev') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 0, item) item = QTableWidgetItem('Ground\n Water\n Level') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 1, item) item = QTableWidgetItem('Porosity') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 2, item) item = QTableWidgetItem('Saturated\n SW') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 3, item) item = QTableWidgetItem('Erodibility') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 4, item) item = QTableWidgetItem('Effective\n cohesion') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 5, item) item = QTableWidgetItem('Internal\n friction\n angle') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 6, item) item = QTableWidgetItem('Suction\n stress\n angle') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(0, 7, item) for k in range(0, len(bankSecData.gradList)): item = QTableWidgetItem( str(bankSecData.gradList[k][0]) + ' - ' + str(bankSecData.gradList[k][1]) + ' mm') item.setFlags(item.flags() & ~Qt.ItemIsEditable) table.setItem(n_layers + 1, k, item) for i in range(1, n_layers + 1): layerData = bankSecData.layerItems[i - 1] table.setItem(i, 0, QTableWidgetItem(str(layerData.minElev))) table.setItem(i, 1, QTableWidgetItem(str(layerData.grdWatLvl))) table.setItem(i, 2, QTableWidgetItem(str(layerData.porosity))) table.setItem(i, 3, QTableWidgetItem(str(layerData.ssw))) table.setItem(i, 4, QTableWidgetItem(str(layerData.erodibility))) table.setItem(i, 5, QTableWidgetItem(str(layerData.coh))) table.setItem(i, 6, QTableWidgetItem(str(layerData.phi))) table.setItem(i, 7, QTableWidgetItem(str(layerData.phib))) for j in range(0, len(layerData.gradList)): item2 = QTableWidgetItem(str(layerData.gradList[j][2])) table.setItem(n_layers + 2 - 1 + i, j, item2)
def set_table_data(self, date): self.target_date_display.setText(date.strftime('%Y-%m-%d')) # Get all sessions on that date previous_sessions = runner.models.Session.objects.filter( date_time_start__date=date).order_by('date_time_start') # Fill out the new daily plan to look just like the old one box_l = sorted([box.name for box in runner.models.Box.objects.all()]) mouse_l = sorted([mouse.name for mouse in runner.models.Mouse.objects.all()]) board_l = sorted([board.name for board in runner.models.Board.objects.all()]) # Set every row with the same widgets # 0 - Mouse, read only # 1 - Weight, text box # 2 - Box, combo box # 3 - Board, combo box # 4 - Previous pipe, read only # 5 - Previous perf, read only # 6 - Start, button # 7 - Performance, read only # 8 - Pipe stop, read only #self.daily_plan_table.setRowCount(len(previous_sessions) + 1) self.daily_plan_table.setRowCount(len(previous_sessions)) for nrow, session in enumerate(previous_sessions): # Mouse name, read only item = QTableWidgetItem(session.mouse.name) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 0, item) # Weight, text box item = QTableWidgetItem(str(session.user_data_weight)) self.daily_plan_table.setItem(nrow, 1, item) # Box, combo box qcb = create_combo_box(box_l, choice=session.box.name) self.daily_plan_table.setCellWidget(nrow, 2, qcb) self.daily_plan_table.setItem(nrow, 2, QTableWidgetItem('')) # Board, combo box qcb = create_combo_box(board_l, choice=session.board.name) self.daily_plan_table.setCellWidget(nrow, 3, qcb) self.daily_plan_table.setItem(nrow, 3, QTableWidgetItem('')) # Previous pipe, read only try: text = '%0.2f' % session.user_data_water_pipe_position_stop except TypeError: text = '' item = QTableWidgetItem(text) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 4, item) # Previous perf, read only try: text = '%0.f; %0.f' % ( 100 * session.user_data_left_perf, 100 * session.user_data_right_perf, ) except TypeError: text = '' item = QTableWidgetItem(text) item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 5, item) # Start, button qb = QPushButton('Start') #~ qb.setCheckable(True) qb.clicked.connect(functools.partial(self.start_session2, qb)) self.daily_plan_table.setCellWidget(nrow, 6, qb) self.daily_plan_table.setItem(nrow, 6, QTableWidgetItem('')) # New perf, read only item = QTableWidgetItem('-') item.setFlags(item.flags() ^ QtCore.Qt.ItemIsEditable) self.daily_plan_table.setItem(nrow, 7, item) # New pipe, text box item = QTableWidgetItem('-') self.daily_plan_table.setItem(nrow, 8, item) item = QTableWidgetItem('') self.daily_plan_table.setItem(nrow, 9, item) # Remove, button rmvButton = QPushButton('Remove') self.daily_plan_table.setCellWidget(nrow, 10, rmvButton) self.daily_plan_table.setItem(nrow, 10, QTableWidgetItem('')) #Necessary to keep track of changing index index = QPersistentModelIndex(self.daily_plan_table.model().index(nrow, 10)) rmvButton.clicked.connect(functools.partial(self.removeRow, index))
def __init__(self, bpms, cors, parent = None): super(OrbitCorrGeneral, self).__init__(parent) self.bpms, self.cors = bpms, cors self.sb = [bpm.sb for bpm in self.bpms] self.x0, self.y0 = None, None self._update_current_orbit() self.table = QTableWidget(len(self.bpms), 9) self.table.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) hdview = QHeaderView(Qt.Horizontal) self.table.setHorizontalHeaderLabels( ['BPM Name', 's', "Beta X", "Beta Y", "Eta X", 'X Bump', 'Y Bump', "Target X", "Target Y"]) self._twiss = getTwiss([b.name for b in self.bpms], ["s", "betax", "betay", "etax"]) for i,bpm in enumerate(self.bpms): it = QTableWidgetItem(bpm.name) it.setFlags(it.flags() & (~Qt.ItemIsEditable)) self.table.setItem(i, 0, it) it = QTableWidgetItem(str(bpm.sb)) it.setFlags(it.flags() & (~Qt.ItemIsEditable)) #it.setMinimumWidth(80) self.table.setItem(i, 1, it) self.table.setItem(i, 2, QTableWidgetItem("%.4f" % self._twiss[i,1])) self.table.setItem(i, 3, QTableWidgetItem("%.4f" % self._twiss[i,2])) self.table.setItem(i, 4, QTableWidgetItem("%.4f" % self._twiss[i,3])) for j in range(5, 9): it = QTableWidgetItem(str(0.0)) it.setData(Qt.DisplayRole, str(0.0)) it.setFlags(it.flags() | Qt.ItemIsEditable) self.table.setItem(i, j, it) # use the current orbit #self.table.item(i,4).setData(Qt.DisplayRole, str(self.x0[i])) #self.table.item(i,5).setData(Qt.DisplayRole, str(self.y0[i])) #self.connect(self.table, SIGNAL("cellClicked(int, int)"), # self._cell_clicked) self.table.resizeColumnsToContents() #self.table.horizontalHeader().setStretchLastSection(True) #for i in range(4): # print "width", i, self.table.columnWidth(i) #self.table.setColumnWidth(0, 300) self.table.setColumnWidth(1, 80) vbox1 = QtGui.QVBoxLayout() frmbox = QFormLayout() self.base_orbit_box = QtGui.QComboBox() #self.base_orbit_box.addItems([ # "Current Orbit", "All Zeros"]) self.base_orbit_box.addItems(["All Zeros", "Current Orbit"]) frmbox.addRow("Orbit Base", self.base_orbit_box) grp = QtGui.QGroupBox("Local Bump") grp.setLayout(frmbox) vbox1.addWidget(grp) frmbox = QFormLayout() hln1 = QtGui.QFrame() hln1.setLineWidth(3) hln1.setFrameStyle(QtGui.QFrame.Sunken) hln1.setFrameShape(QtGui.QFrame.HLine) frmbox.addRow(hln1) self.repeatbox = QSpinBox() self.repeatbox.setRange(1, 20) self.repeatbox.setValue(3) # or connect the returnPressed() signal frmbox.addRow("&Repeat correction", self.repeatbox) self.rcondbox = QLineEdit() self.rcondbox.setValidator(QDoubleValidator(0, 1, 0, self)) self.rcondbox.setText("1e-2") frmbox.addRow("r&cond for SVD", self.rcondbox) self.scalebox = QDoubleSpinBox() self.scalebox.setRange(0.01, 5.00) self.scalebox.setSingleStep(0.01) self.scalebox.setValue(0.68) frmbox.addRow("&Scale correctors", self.scalebox) #hln2 = QtGui.QFrame() #hln2.setLineWidth(3) #hln2.setFrameStyle(QtGui.QFrame.Sunken) #hln2.setFrameShape(QtGui.QFrame.HLine) #frmbox.addRow(hln2) self.progress = QProgressBar() self.progress.setMaximum(self.repeatbox.value()) self.progress.setMaximumHeight(15) frmbox.addRow("Progress", self.progress) grp = QtGui.QGroupBox("Correction") grp.setLayout(frmbox) vbox1.addWidget(grp) #vbox.addStretch(1.0) #self.qdb = QDialogButtonBox(self) #self.qdb.addButton("APP", QDialogButtonBox.ApplyRole) #self.qdb.addButton("R", QDialogButtonBox.ResetRole) #btn.setDefault(True) #self.qdb.addButton(QDialogButtonBox.Cancel) #self.qdb.addButton(QDialogButtonBox.Help) gbox = QtGui.QGridLayout() btn = QPushButton("Clear") self.connect(btn, SIGNAL("clicked()"), self.resetBumps) gbox.addWidget(btn, 0, 1) self.correctOrbitBtn = QPushButton("Apply") #self.correctOrbitBtn.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.correctOrbitBtn.setStyleSheet("QPushButton:disabled { color: gray }"); self.connect(self.correctOrbitBtn, SIGNAL("clicked()"), self.call_apply) self.correctOrbitBtn.setDefault(True) gbox.addWidget(self.correctOrbitBtn, 1, 1) gbox.setColumnStretch(0, 1) vbox1.addStretch() vbox1.addLayout(gbox) hbox1 = QtGui.QHBoxLayout() hbox1.addWidget(self.table, 2) hbox1.addLayout(vbox1, 0) self.setLayout(hbox1) self.connect(self.base_orbit_box, SIGNAL("currentIndexChanged(QString)"), self.updateTargetOrbit) self.connect(self.repeatbox, SIGNAL("valueChanged(int)"), self.progress.setMaximum) self.connect(self.table, SIGNAL("cellChanged (int, int)"), self.updateBump)
def make_item(data, readonly=True): item = QTableWidgetItem(str(data)) if readonly: item.setFlags(item.flags() ^ Qt.ItemIsEditable) return item