def updateList(self): self.portList.clear() self.backup_indixes = list(self.gui.song.outputsPorts) for name in self.backup_indixes: this_item = QListWidgetItem(name) this_item.setFlags(this_item.flags()) self.portList.addItem(this_item)
def readSettings(self): self.inputTextList.clear() entries = settings.metricsWindowComboBoxItems() for entry in entries: item = QListWidgetItem(entry, self.inputTextList) item.setFlags(item.flags() | Qt.ItemIsEditable) if not len(entries): self.removeItemButton.setEnabled(False)
def refresh_list(self): self.input.clear() if not self._parameter.ordering == InputListParameter.NotOrdered: self._value_cache.sort() if self._parameter.ordering == InputListParameter.DescendingOrder: self._value_cache.reverse() for opt in self._value_cache: item = QListWidgetItem() item.setText(str(opt)) item.setFlags(item.flags() | Qt.ItemIsEditable) self.input.addItem(item)
def __init__(self, parameter, parent=None): """Constructor .. versionadded:: 2.2 :param parameter: A ListParameter object. :type parameter: ListParameter """ super().__init__(parameter, parent) self._input = QListWidget() self._input.setSelectionMode(QAbstractItemView.MultiSelection) if self._parameter.maximum_item_count != \ self._parameter.minimum_item_count: tool_tip = 'Select between %d and %d items' % ( self._parameter.minimum_item_count, self._parameter.maximum_item_count) else: tool_tip = 'Select exactly %d items' % ( self._parameter.maximum_item_count) self._input.setToolTip(tool_tip) for opt in self._parameter.options_list: item = QListWidgetItem() item.setFlags(item.flags() | Qt.ItemIsEditable) item.setText(str(opt)) self._input.addItem(item) if opt in self._parameter.value: item.setSelected(True) self.inner_input_layout.addWidget(self._input) # override self._input_layout arrangement to make the label at the top # reset the layout self.input_layout.setParent(None) self.help_layout.setParent(None) self.label.setParent(None) self.inner_input_layout.setParent(None) self.input_layout = QVBoxLayout() self.input_layout.setSpacing(0) # put element into layout self.input_layout.addWidget(self.label) self.input_layout.addLayout(self.inner_input_layout) self.main_layout.addLayout(self.input_layout) self.main_layout.addLayout(self.help_layout)
def _groupAdd(self): groupName = "New group" if groupName in self.font.groups: index = 1 while "%s %d" % (groupName, index) in self.font.groups: index += 1 groupName = "%s %d" % (groupName, index) self.font.groups[groupName] = [] item = QListWidgetItem(groupName, self.groupsList) item.setFlags(item.flags() | Qt.ItemIsEditable) self.groupsList.setCurrentItem(item) self.groupsList.editItem(item) self.removeGroupButton.setEnabled(True)
def addGlyphSet(self, glyphNames=[], glyphSetName=None): if glyphSetName is None: glyphSetName = self.tr("New glyph set") if glyphSetName in self.glyphSets: index = 1 while "%s %d" % (glyphSetName, index) in self.glyphSets: index += 1 glyphSetName = "%s %d" % (glyphSetName, index) self.glyphSets[glyphSetName] = glyphNames item = QListWidgetItem(glyphSetName, self.glyphSetList) item.setFlags(item.flags() | Qt.ItemIsEditable) self.glyphSetList.setCurrentItem(item) self.glyphSetList.editItem(item) self.removeGlyphSetButton.setEnabled(True)
def list_file(self, file_list): self.list_widget.clear() self.file_list = file_list for file in file_list.keys(): self.file_list[file].append(os.path.splitext(file)[-1][1:]) pixmap = get_pixmap(file, file_list[file][0]) widget_item = FileItem(pixmap, file, file_list[file][0]) widget_item.rename_signal.connect(self.rename) list_item = QListWidgetItem() list_item.setSizeHint(QSize(200, 200)) self.list_widget.addItem(list_item) self.list_widget.setItemWidget(list_item, widget_item) add_file_widget = FileItem(QPixmap(':/default/default_pngs/add.png'), '添加文件', False) add_file_item = QListWidgetItem() add_file_item.setSizeHint(QSize(200, 200)) add_file_item.setFlags(add_file_item.flags() & ~Qt.ItemIsEnabled & ~Qt.ItemIsSelectable) self.list_widget.addItem(add_file_item) self.list_widget.setItemWidget(add_file_item, add_file_widget)
def add(self): (text, ok) = QInputDialog.getText(self, translate('Actions', "New Action"), translate('Actions', "Enter a name for the new action."), QLineEdit.EchoMode.Normal) if (ok is True) and text: item = QListWidgetItem(text) item.setCheckState(Qt.CheckState.Unchecked) item.setFlags(item.flags() | Qt.ItemFlag.ItemIsEditable) self.listbox.addItem(item) else: return win = CreateAction(self, example=self.example) win.setWindowTitle(translate('Actions', "Add Action: ") + \ self.listbox.item(self.listbox.count() - 1).text()) win.setModal(True) win.donewithmyshit.connect(self.addBuddy) win.rejected.connect(lambda: self.listbox.takeItem(self.listbox.count() - 1)) win.show()
def retrieve_params(self): """This function is trigged by "edit" table, and basically fills the left list widget, all attributes that have a index get selected by default.""" c = 0 for item in self.items_in_table: if item.checkState() == 2: c += 1 table = item.text() if c != 1: QMessageBox.information(None, self.tr("Error:"), self.tr('You can only have one dataset selected')) return self.current_schema, self.current_table = table.split('.') if self.params_in_list != 0: model = self.TMD.SAParams.model() for item in self.params_in_table: qIndex = self.TMD.SAParams.indexFromItem(item) model.removeRow(qIndex.row()) self.params_in_list = 0 checked_params = [] table = self.current_table schema = self.current_schema indexes = self.db.get_indexes(table, schema) for nbr in indexes.keys(): checked_params.append(indexes[nbr]['index_col']) columns = self.db.get_all_columns(table, schema) for param_name in columns: if param_name[0] in ['cmin', 'xmin', 'xmax', 'cmax', 'ctid', 'pos', 'polygon', 'tableoid', '_', 'field_row_id']: continue if param_name[0][:3] == '...': continue item_name = str(param_name[0]) testcase_name = QtCore.QCoreApplication.translate("qadashboard", item_name, None) item = QListWidgetItem(testcase_name, self.TMD.SAParams) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) if param_name[0] in checked_params: item.setCheckState(QtCore.Qt.Checked) else: item.setCheckState(QtCore.Qt.Unchecked) self.params_in_list += 1 self.params_in_table = self.TMD.SAParams.findItems('', QtCore.Qt.MatchContains)
def add_crop(self): """Adds a crop to the database""" crop_name = self.dock_widget.LECropName.text() if len(crop_name) == 0: QMessageBox.information(None, self.tr('Error:'), self.tr('Crop name must be filled in.')) return sql = """Insert into crops (crop_name) VALUES ('{name}')""".format(name=crop_name) r_value = self.db.execute_sql(sql, return_failure=True) if r_value is IntegrityError: QMessageBox.information( None, self.tr('Error:'), self.tr('Crop name already exist, please select a new name')) return _name = QApplication.translate("qadashboard", crop_name, None) item = QListWidgetItem(_name, self.dock_widget.LWCrops) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) self.populate.reload_crops()
def update_table_list(self): """Update the list of tables in the docket widget""" lw_list = self.parent.populate.get_lw_list() if self.tables_in_db != 0: model = self.TMD.SATables.model() for item in self.items_in_table: qIndex = self.TMD.SATables.indexFromItem(item) model.removeRow(qIndex.row()) self.tables_in_db = 0 for lw, schema in lw_list: table_names = self.db.get_tables_in_db(schema) for name in table_names: if str(name[0]) in ['harrowing_manual', 'plowing_manual', 'manual']: continue item_name = schema + '.' + str(name[0]) testcase_name = QtCore.QCoreApplication.translate("qadashboard", item_name, None) item = QListWidgetItem(testcase_name, self.TMD.SATables) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) self.tables_in_db += 1 self.items_in_table = self.TMD.SATables.findItems('', QtCore.Qt.MatchContains)
def save(self): """Saves the field in the database""" try: self.iface.actionSaveActiveLayerEdits().trigger() self.iface.actionToggleEditing().trigger() feature = self.field.getFeature(1) QgsProject.instance().removeMapLayers([self.field.id()]) except: QMessageBox.information( None, self.tr("Error:"), self. tr('No coordinates where found, did you mark the field on the canvas?' )) return polygon = feature.geometry().asWkt() name = self.AFD.LEFieldName.text() if len(name) == 0: QMessageBox.information(None, self.tr('Error:'), self.tr('Field name must be filled in.')) return sql = """Insert into fields (field_name, polygon) VALUES ('{name}', st_geomfromtext('{poly}', 4326))""".format( name=name, poly=polygon) try: self.db.execute_sql(sql) except IntegrityError: QMessageBox.information( None, self.tr('Error:'), self.tr( 'Field name all ready exist, please select a new name')) return except InternalError as e: QMessageBox.information(None, self.tr('Error:'), str(e)) return _name = QApplication.translate("qadashboard", name, None) item = QListWidgetItem(_name, self.dock_widget.LWFields) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) self.defined_field = name self.view_fields()
def render_aliases(self): self.AliasesList.clear() aliases = self.manager.aliases.data pattern = self.AliasesFilter.text() + '*' def sort_by_name(item): alias, _ = item return alias def sort_by_time(item): alias, _ = item return (self.manager.paths.blobs / self.manager.aliases.get_selection(alias)).stat().st_mtime sort_key, sort_reverse = { AliasSortMode.by_name_asc: (sort_by_name, False), AliasSortMode.by_name_desc: (sort_by_name, True), AliasSortMode.by_time_asc: (sort_by_time, False), AliasSortMode.by_time_desc: (sort_by_time, True) }[self.alias_sort_mode] for alias, blob_ids in sorted(aliases.items(), key=sort_key, reverse=sort_reverse): if pattern and not fnmatch.fnmatch(alias, pattern): continue list_item = QListWidgetItem() list_item.setText(alias) list_item.setData(Qt.UserRole, { 'alias': alias, 'blob_ids': blob_ids }) list_item.setFlags(list_item.flags() | Qt.ItemIsEditable) self.AliasesList.addItem(list_item) if self.current_selected_alias == alias: self.AliasesList.setCurrentItem(list_item) if aliases and not self.AliasesList.currentItem(): self.AliasesList.setCurrentRow(0) if not self.AliasesList.currentItem(): self.current_selected_alias = None
def setEditorData(self, editor, index): if index.isValid() and ((index.column() == 1 and index.internalPointer().hasMin()) \ or (index.column() == 2 and (index.internalPointer().hasMax() or \ isinstance(index.internalPointer(),filters.InSetFilter)))): if index.column() == 1 and index.internalPointer().hasMin(): editor.setValue(index.internalPointer().minimum) elif index.column() == 2 and index.internalPointer().hasMax(): editor.setValue(index.internalPointer().maximum) elif index.column() == 2 and isinstance(index.internalPointer(), filters.InSetFilter): lwidget = QListWidget(editor) lwidget.addItem(index.internalPointer().valuesString()) if index.model().dmodel.hasLabels( index.internalPointer().field): lwidget.addItems(index.model().dmodel.labels( index.internalPointer().field)) for i in range(1, lwidget.count()): lwidget.item(i).setFlags( lwidget.item(i).flags() | Qt.ItemIsUserCheckable) # i-1 because item 0 is the full list so need to offset all by -1 lwidget.item(i).setCheckState( index.model().dmodel.intValue( index.internalPointer().field, lwidget.item(i).text()) in index.internalPointer().allowed) else: numbers = np.unique(index.internalPointer().values) for n in numbers: i = QListWidgetItem(str(int(n))) i.setFlags(i.flags() | Qt.ItemIsUserCheckable) i.setCheckState(n in index.internalPointer().allowed) lwidget.addItem(i) editor.setModel(lwidget.model()) editor.setView(lwidget) editor.currentIndexChanged.connect(self.onComboChange) elif index.column() == 2 and isinstance(index.internalPointer(), filters.GroupFilter): pass else: super(FilterItemDelegate, self).setEditorData(editor, index)
def update_gui(self): selected_file_names = [selection_el.text() for selection_el in self.file_selection_listwidget.selectedItems()] # computing_group hyd_names = get_filename_by_type_physic("hydraulic", os.path.join(self.path_prj, "hdf5")) hab_names = get_filename_by_type_physic("habitat", os.path.join(self.path_prj, "hdf5")) names = hyd_names + hab_names self.file_selection_listwidget.blockSignals(True) self.file_selection_listwidget.clear() self.hs_computed_listwidget.blockSignals(True) self.hs_computed_listwidget.clear() if names: for name in names: # filename item_name = QListWidgetItem() item_name.setText(name) self.file_selection_listwidget.addItem(item_name) if name in selected_file_names: item_name.setSelected(True) # check item = QListWidgetItem() item.setText("") item.setFlags(item.flags() | Qt.ItemIsUserCheckable) try: hdf5 = Hdf5Management(self.path_prj, name, new=False, edit=False) hdf5.get_hdf5_attributes(close_file=True) if hdf5.hs_calculated: item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) except: self.send_log.emit(self.tr("Error: " + name + " file seems to be corrupted. Delete it with HABBY or manually.")) self.hs_computed_listwidget.addItem(item) item.setTextAlignment(Qt.AlignCenter) self.file_selection_listwidget.blockSignals(False) self.hs_computed_listwidget.blockSignals(False) # preselection if one if self.file_selection_listwidget.count() == 1: self.file_selection_listwidget.selectAll()
def update_assigees_gui(self): # update the assignee gui list # TODO Cleanup self.listWidget.clear() self.comboBoxAssignee.clear() self.comboBoxReporter.clear() for a in self.assignees: item = QListWidgetItem() item.setText(a[0]) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) # TODO need to fix that they get all get checked when a new user is added item.setCheckState(Qt.Checked) self.listWidget.addItem(item) self.comboBoxAssignee.addItem(a[0]) self.comboBoxReporter.addItem(a[0]) assert len(self.assignees) == len(self.listWidget) # TODO this reuqires cleanup there should not be duplicated reportes and assignees assert len(self.assignees) == len(self.comboBoxAssignee) assert len(self.assignees) == len(self.comboBoxReporter)
def __loadScripts(self): """ Private method to load all the available scripts. """ for script in self.__manager.allScripts(): itm = QListWidgetItem( UI.PixmapCache.getIcon("greaseMonkeyScript.png"), script.name(), self.scriptsList) itm.setData( GreaseMonkeyConfigurationDialog.ScriptVersionRole, script.version()) itm.setData( GreaseMonkeyConfigurationDialog.ScriptDescriptionRole, script.description()) itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable) if script.isEnabled(): itm.setCheckState(Qt.Checked) else: itm.setCheckState(Qt.Unchecked) itm.setData(GreaseMonkeyConfigurationDialog.ScriptRole, script) self.scriptsList.addItem(itm) self.scriptsList.sortItems() itemMoved = True while itemMoved: itemMoved = False for row in range(self.scriptsList.count()): topItem = self.scriptsList.item(row) bottomItem = self.scriptsList.item(row + 1) if topItem is None or bottomItem is None: continue if topItem.checkState() == Qt.Unchecked and \ bottomItem.checkState == Qt.Checked: itm = self.scriptsList.takeItem(row + 1) self.scriptsList.insertItem(row, itm) itemMoved = True
def _makeItem(self, layer): isDefault = layer is self._layerSet.defaultLayer name = layer.name color = layer.color item = QListWidgetItem() item.setText(name) if color: pixmap = QPixmap(100, 100) # change color pixmap.fill(QColor.fromRgbF(*color)) icon = QIcon(pixmap) else: icon = QIcon(":/resources/defaultColor.svg") item.setIcon(icon) if isDefault: font = item.font() font.setBold(True) item.setFont(font) item.setFlags(item.flags() | Qt.ItemIsEditable) return item;
def readSettings(self): defaultGlyphSet = settings.defaultGlyphSet() self.defaultGlyphSetBox.setChecked(len(defaultGlyphSet)) self.glyphSets = settings.readGlyphSets() self.defaultGlyphSetDrop.clear() self.defaultGlyphSetDrop.addItems(self.glyphSets.keys()) self.glyphSetList.clear() glyphSetNames = self.glyphSets.keys() # Normally we should be enforcing this rather decently in the interface # already if glyphSetNames: for glyphSetName in glyphSetNames: item = QListWidgetItem(glyphSetName, self.glyphSetList) item.setFlags(item.flags() | Qt.ItemIsEditable) self.glyphSetList.setCurrentRow(0) self.removeGlyphSetButton.setEnabled(len(self.glyphSets) > 1) glyphListPath = settings.glyphListPath() self.glyphListBox.setChecked(bool(glyphListPath)) self.glyphListEdit.setEnabled(bool(glyphListPath)) self.glyphListEdit.setText(glyphListPath) self.glyphListButton.setEnabled(bool(glyphListPath))
def add_pic_fromData(self, data, boshowsize=True): if not data: return pixmap = None if isinstance(data, str): if os.path.isfile(data): pixmap = QPixmap(data) elif isinstance(data, bytes): pixmap = QPixmap() pixmap.loadFromData(data) if not pixmap: return icon = QIcon(pixmap) s_size = '' if boshowsize: s_size = '{}*{}'.format(pixmap.width(), pixmap.height()) item = QListWidgetItem(icon, self.tr(s_size)) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Checked) self.addItem(item) self.scrollToItem(item)
def __init__(self, parent=None): super(PredictorSelectionDialog, self).__init__(parent) self.setWindowTitle( "Enable/Disable Predictors for Annotation Prediction") self.setWindowModality(Qt.ApplicationModal) layout = QVBoxLayout(self) # predictor list self.predictor_list = QListWidget() self.predictor_list.setSelectionMode(QAbstractItemView.NoSelection) for predictor in config.prediction_pipeline.get_all_predictors(): item = QListWidgetItem(predictor.name, self.predictor_list, 0) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Checked if predictor. is_prediction_enabled else Qt.Unchecked) self.predictor_list.addItem(item) layout.addWidget(self.predictor_list) # buttons buttons = QDialogButtonBox( QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons)
def showListImages(self): listwidget_size = self.ui.listWidget.size() # 计算缩放比例 self.scaleFactor1 = self.frameWidth / listwidget_size.width() self.iconWidth = listwidget_size.width() self.iconHeight = int(self.frameHeight / self.scaleFactor1) self.ui.listWidget.clear() self.ui.listWidget.setViewMode(QListView.IconMode) self.ui.listWidget.setIconSize( QtCore.QSize(self.iconWidth, self.iconHeight)) self.ui.listWidget.setResizeMode(QListView.Adjust) self.ui.listWidget.setMovement(QListView.Static) # Listview显示状态 # self.ui.listWidget.setMaximumHeight() #设置最大高宽 self.ui.listWidget.setSpacing(12) # 间距大小 for idx, file_path in enumerate(self.frame_paths): item = QListWidgetItem(QtGui.QIcon(file_path), self.frame_names[idx]) item.setTextAlignment(QtCore.Qt.AlignHCenter) item.setFlags(item.flags() ^ Qt.ItemIsUserCheckable) # if self._has_label_file(idx): # item.setCheckState(Qt.Checked) # else: # item.setCheckState(Qt.Unchecked) self.ui.listWidget.addItem(item)
def reload_fields(self, cmd_box=None): """Reloads all field comboBoxes in the GeoDataFarm widget Parameters ---------- cmd_box: QtComboBox, optional a comboBox to fill with the field names (used in text_data_handler)""" if cmd_box is None: cmd_box = [ self.dw.CBPField, self.dw.CBFField, self.dw.CBSpField, self.dw.CBOField, self.dw.CBHvField, self.dw.CBPloField, self.dw.CBHwField, self.dw.CBIField, self.dw.CBSoField ] fields = self.db.get_distinct('fields', 'field_name', 'public') lw = self.dw.LWFields lw.clear() for field_name in fields: _na = QApplication.translate("qadashboard", field_name[0], None) item = QListWidgetItem(_na, self.dw.LWFields) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) else: cmd_box = [cmd_box] fields_ = self.db.execute_and_return( "select field_name from fields order by field_name") fields = [] for field in fields_: fields.append(field[0]) for i, lw in enumerate(cmd_box): if len(self.fields) > 1: lw.clear() lw.addItem(self.tr('--- Select field ---')) for name in fields: lw.addItem(str(name)) self.fields = [self.tr('--- Select field ---')] self.fields.extend(fields)
def putSlot(self, filename): downloadtask = QListWidgetItem(self.tasklist) self.tasklist.addItem(downloadtask) dlvlay = QHBoxLayout() listwidget = QWidget(self) typelabel = QLabel('Upload') dlfilename = QLabel(filename[:30]) downloadprogress = QProgressBar(self) dlbutton = QPushButton('Pause') dlvlay.addWidget(typelabel, 1) dlvlay.addWidget(dlfilename, 2) dlvlay.addWidget(downloadprogress, 6) dlvlay.addWidget(dlbutton, 1) listwidget.setLayout(dlvlay) downloadtask.setSizeHint(listwidget.sizeHint()) downloadtask.setFlags(downloadtask.flags() & ~Qt.ItemIsSelectable) self.tasklist.setItemWidget(downloadtask, listwidget) path = self.localfileModel.path / filename putPauseflag = { 'stop': False, 'button': dlbutton, 'dlpb': downloadprogress, 'localname': path, 'remotefullpath': self.remotefileModel.path, 'remotename': filename } self.putFlags.append(putPauseflag) id = len(self.putFlags) - 1 dlbutton.clicked.connect(self.putPauseSlot(id)) worker = putWorker(self.ftp, path, filename, 0, downloadprogress, self.putUpdatePBSlot, self.putFinishSlot, putPauseflag, id) self.threadpool.start(worker)
def __loadScripts(self): """ Private method to load all the available scripts. """ for script in self.__manager.allScripts(): itm = QListWidgetItem( UI.PixmapCache.getIcon("greaseMonkeyScript.png"), script.name(), self.scriptsList) itm.setData(GreaseMonkeyConfigurationDialog.ScriptVersionRole, script.version()) itm.setData(GreaseMonkeyConfigurationDialog.ScriptDescriptionRole, script.description()) itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable) if script.isEnabled(): itm.setCheckState(Qt.Checked) else: itm.setCheckState(Qt.Unchecked) itm.setData(GreaseMonkeyConfigurationDialog.ScriptRole, script) self.scriptsList.addItem(itm) self.scriptsList.sortItems() itemMoved = True while itemMoved: itemMoved = False for row in range(self.scriptsList.count()): topItem = self.scriptsList.item(row) bottomItem = self.scriptsList.item(row + 1) if topItem is None or bottomItem is None: continue if topItem.checkState() == Qt.Unchecked and \ bottomItem.checkState == Qt.Checked: itm = self.scriptsList.takeItem(row + 1) self.scriptsList.insertItem(row, itm) itemMoved = True
def update_table_list(self): """Update the list of tables in the docket widget""" for i, (lw, schema) in enumerate(self.lw_list): table_names = self.db.get_tables_in_db(schema) # If already added, starts with cleaning the lw if self.tables_in_db[i] != 0: lw.clear() self.tables_in_db[i] = 0 for name in table_names: if name in [ "spatial_ref_sys", "pointcloud_formats", "temp_polygon", "manual", "plowing_manual", "harrowing_manual" ]: continue _name = QApplication.translate("qadashboard", name, None) item = QListWidgetItem(_name, lw) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) self.tables_in_db[i] += 1 self.items_in_table[i][0] = lw.findItems('', QtCore.Qt.MatchContains) self.items_in_table[i][1] = schema self.items_in_table[i][2] = lw
def fillGroupNames(self, groupNames): for groupName in groupNames: item = QListWidgetItem(groupName, self) item.setFlags(item.flags() | Qt.ItemIsEditable)
def addCheckableItem(self, item, listView, state=False): newItem = QListWidgetItem(item, listView) newItem.setCheckState(state) newItem.setFlags(newItem.flags() | QtCore.Qt.ItemIsUserCheckable)
def addItem(self): item = QListWidgetItem(self.inputTextList) item.setFlags(item.flags() | Qt.ItemIsEditable) self.inputTextList.setCurrentItem(item) self.inputTextList.editItem(item) self.removeItemButton.setEnabled(True)
def __init__(self, browser, parent=None): """ Constructor @param browser reference to the browser window (HelpBrowser) @param parent reference to the parent widget (QWidget) """ super(SiteInfoDialog, self).__init__(parent) self.setupUi(self) self.setWindowFlags(Qt.Window) # put icons self.tabWidget.setTabIcon( 0, UI.PixmapCache.getIcon("siteinfo-general.png")) self.tabWidget.setTabIcon( 1, UI.PixmapCache.getIcon("siteinfo-media.png")) self.tabWidget.setTabIcon( 2, UI.PixmapCache.getIcon("siteinfo-databases.png")) if SSL: self.tabWidget.setTabIcon( 3, UI.PixmapCache.getIcon("siteinfo-security.png")) self.__mainFrame = browser.page().mainFrame() title = browser.title() sslInfo = browser.page().getSslCertificateChain() # populate General tab self.heading.setText("<b>{0}</b>".format(title)) self.siteAddressLabel.setText(self.__mainFrame.baseUrl().toString()) self.sizeLabel.setText(dataString(browser.page().totalBytes())) encoding = "" # populate Meta tags meta = self.__mainFrame.findAllElements("meta") for element in meta: content = element.attribute("content") name = element.attribute("name") if not name: name = element.attribute("http-equiv") if element.attribute("charset"): encoding = element.attribute("charset") if "charset=" in content: encoding = content[content.index("charset=") + 8:] if not content or not name: continue QTreeWidgetItem(self.tagsTree, [name, content]) for col in range(self.tagsTree.columnCount()): self.tagsTree.resizeColumnToContents(col) if not encoding: encoding = QWebSettings.globalSettings().defaultTextEncoding() self.encodingLabel.setText(encoding) # populate the Security info and the Security tab if sslInfo and \ ((qVersion() >= "5.0.0" and not sslInfo[0].isBlacklisted()) or (qVersion() < "5.0.0" and sslInfo[0].isValid())): self.securityLabel.setStyleSheet(SiteInfoDialog.okStyle) self.securityLabel.setText('<b>Connection is encrypted.</b>') if SSL: self.sslWidget.showCertificateChain(sslInfo) self.securityDetailsButton.setEnabled(True) else: self.securityDetailsButton.setEnabled(False) else: self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle) self.securityLabel.setText('<b>Connection is not encrypted.</b>') self.securityDetailsButton.setEnabled(False) self.tabWidget.setTabEnabled( self.tabWidget.indexOf(self.securityTab), False) # populate Media tab images = self.__mainFrame.findAllElements("img") for element in images: src = element.attribute("src") alt = element.attribute("alt") if src and src.startswith("data:"): continue if not alt: if src.find("/") == -1: alt = src else: pos = src.find("/") alt = src[pos + 1:] if not src or not alt: continue QTreeWidgetItem(self.imagesTree, [alt, src]) for col in range(self.imagesTree.columnCount()): self.imagesTree.resizeColumnToContents(col) if self.imagesTree.columnWidth(0) > 300: self.imagesTree.setColumnWidth(0, 300) self.imagesTree.setCurrentItem(self.imagesTree.topLevelItem(0)) self.imagesTree.setContextMenuPolicy(Qt.CustomContextMenu) self.imagesTree.customContextMenuRequested.connect( self.__imagesTreeContextMenuRequested) # populate the Databases tab databases = self.__mainFrame.securityOrigin().databases() counter = 0 for database in databases: itm = QListWidgetItem(self.databasesList) itm.setText(database.displayName()) itm.setData(Qt.UserRole, counter) counter += 1 if counter == 0: itm = QListWidgetItem(self.databasesList) itm.setText(self.tr("No databases are used by this page.")) itm.setFlags(itm.flags() & Qt.ItemIsSelectable)
def plot_data(self): today = date.today() if config.環境 == "本番" else config.デバッグ日付 if self.提供日 is None: #デフォルトでは今日発注のものを表示 self.注文リスト = find注文発注日(today, self.社員.社員番号) if len(self.注文リスト) > 0: self.提供日 = self.注文リスト[0].提供日 else: #今日注文したものがない場合は翌日提供日のメニューを出すのがデフォルト self.提供日 = today + timedelta(days=1) else: self.注文リスト = find注文提供日(self.提供日, self.社員.社員番号) #締切時間表示 if self.提供日 == today + timedelta(days=1): self.ui.labelDeadLine.setVisible(True) self.ui.labelDeadLine.setText( f"発注締切時刻: {time.strftime(config.発注締切時刻, '%H時%M分')}") else: self.ui.labelDeadLine.setVisible(False) self.メニューリスト = findメニュー提供日(self.提供日) self.ui.labelToday.setText(date.strftime(self.提供日, '%m月%d日(%a)')) self.ui.labelStaffName.setText(self.社員.社員名称) self.ui.listMorning.clear() self.ui.listLunch.clear() for 食事種類 in 食事種類型: #朝、昼でそれぞれメニューを抽出してループ処理 抽出メニューリスト = list(filter(lambda メニュー: メニュー.種類 == 食事種類, self.メニューリスト)) #提供時刻表示 targetLabel = self.ui.labelMorningTime if 食事種類 == 食事種類型.朝食 else self.ui.labelLunchTime if len(抽出メニューリスト) > 0: (開始時刻, _) = find提供時刻(self.社員, 抽出メニューリスト[0]) targetLabel.setText(time.strftime(開始時刻, '%H:%M')) else: targetLabel.setText("") for メニュー in 抽出メニューリスト: menuItem = QListWidgetItem(メニュー.内容) menuItem.setFont(QFont(QFont().defaultFamily(), 48)) 注文検索結果 = list( filter(lambda 注文: 注文.メニューID == メニュー.メニューID, self.注文リスト)) if len(注文検索結果) > 0: #注文あり self.setStatus(menuItem, checkStatus.On) else: #注文なし self.setStatus(menuItem, checkStatus.Off) #カロリー、食塩などの情報行 最大提供数表示 = "" if not メニュー.isUnlimit: 最大提供数表示 = f"最大提供数:{メニュー.最大提供数}" extraInfoItem = QListWidgetItem( f"カロリー:{メニュー.カロリー}kcal 食塩:{メニュー.食塩}g 注文数:{self.getCurrentOrderAmount(メニュー)} {最大提供数表示} " ) extraInfoItem.setFont(QFont(QFont().defaultFamily(), 20)) extraInfoItem.setTextAlignment(Qt.AlignRight) extraInfoItem.setFlags(Qt.ItemIsEnabled) blankItem = QListWidgetItem("") blankItem.setFont(QFont(QFont().defaultFamily(), 14)) blankItem.setFlags(menuItem.flags() ^ Qt.ItemIsSelectable) #注文可能数を超えてないか確認 if self.isOrderLimit(メニュー) and not self.isAlreadyOrder(メニュー): menuItem.setFlags(menuItem.flags() ^ Qt.ItemIsEnabled) extraInfoItem.setFlags(extraInfoItem.flags() ^ Qt.ItemIsEnabled) else: menuItem.setData(Qt.UserRole, メニュー.内容) # hidden data targetList = self.ui.listMorning if 食事種類 == 食事種類型.朝食 else self.ui.listLunch targetList.addItem(menuItem) targetList.addItem(extraInfoItem) targetList.addItem(blankItem)
def addItem(self): title = "Sujet {:d}".format(self.listWidget.count()+1) item = QListWidgetItem(title) item.setFlags(item.flags() | Qt.ItemIsEditable) self.listWidget.addItem(item) self.functions.addSubject(title)
def populateListWidget(self): self.model.load_verses() for passage in self.model.passages: item = QListWidgetItem(passage, self.view.listWidget) item.setFlags(item.flags() | QtCore.Qt.ItemIsEditable) self.view.listItems.append(item)
def __init__(self, parent=None, example=None, quickaction=None): """tags are the tags to be shown in the FunctionDialog""" QDialog.__init__(self, parent) self.setWindowTitle(translate('Actions', "Actions")) winsettings('actions', self) self._shortcuts = [] self._quickaction = quickaction self.listbox = ListBox() self.listbox.setSelectionMode(QAbstractItemView.ExtendedSelection) self.listbox.setEditTriggers(QAbstractItemView.EditKeyPressed) self.example = example self.macros = self.loadMacros() cparser = PuddleConfig() self.__configKey = 'quick_actions' if quickaction else 'actions' to_check = cparser.get(self.__configKey, 'checked', []) for i, m in sorted(self.macros.items()): item = QListWidgetItem(m.name) item.setFlags(item.flags() | Qt.ItemIsEditable) if m.name in to_check: item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) self.listbox.addItem(item) self.okcancel = OKCancel() self.okcancel.okButton.setDefault(True) x = QAction(translate('Actions', 'Assign &Shortcut'), self) self.shortcutButton = QToolButton() self.shortcutButton.setDefaultAction(x) x.setToolTip(translate('Actions', '''<p>Creates a shortcut for the checked actions on the Actions menu. Use Edit Shortcuts (found by pressing down on this button) to edit shortcuts after the fact.</p>''')) menu = QMenu(self) edit_shortcuts = QAction(translate('Actions', 'Edit Shortcuts'), menu) edit_shortcuts.triggered.connect(self.editShortcuts) menu.addAction(edit_shortcuts) self.shortcutButton.setMenu(menu) self.okcancel.insertWidget(0, self.shortcutButton) self.grid = QGridLayout() self.buttonlist = ListButtons() self.grid.addWidget(self.listbox, 0, 0) self.grid.setRowStretch(0, 1) self.grid.addLayout(self.buttonlist, 0, 1) self.setLayout(self.grid) self.okcancel.ok.connect(self.okClicked) self.okcancel.cancel.connect(self.close) self.buttonlist.add.connect(self.add) self.buttonlist.edit.connect(self.edit) self.buttonlist.moveup.connect(self.moveUp) self.buttonlist.movedown.connect(self.moveDown) self.buttonlist.remove.connect(self.remove) self.buttonlist.duplicate.connect(self.duplicate) self.listbox.itemDoubleClicked.connect(self.edit) self.listbox.currentRowChanged.connect(self.enableListButtons) self.listbox.itemChanged.connect(self.renameAction) self.listbox.itemChanged.connect(self.enableOK) self.shortcutButton.clicked.connect(self.createShortcut) self._examplelabel = ScrollLabel('') self.grid.addWidget(self._examplelabel, 1, 0, 1, -1) self.grid.setRowStretch(1, 0) if example is None: self._examplelabel.hide() self.listbox.itemChanged.connect(self.updateExample) self.grid.addLayout(self.okcancel, 2, 0, 1, 2) self.updateExample() self.enableOK(None)
def set_toasting(self, item: QListWidgetItem): with self.toasting_lock: drive = item.text() item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEnabled ) # ~QtCore.Qt.ItemIsSelectable is redundant self.toasting[drive] = item
def __init__(self, _format, parent=None): QWidget.__init__(self, parent) self.setupUi(self) self.toolBox.setStyleSheet(S.toolBoxSS()) self.mw = mainWindow() self._format = _format self.settings = {} ################################################################# # Content self.grpContentFilters.button.setChecked(False) h = self.tblContent.horizontalHeader() h.setSectionResizeMode(h.ResizeToContents) h.setSectionResizeMode(0, h.Stretch) self.contentUpdateTable() self.chkContentMore.toggled.connect(self.contentTableToggle) self.contentTableToggle(False) # Labels self.lstContentLabels.clear() h = QFontMetrics(self.font()).height() for i in range(0, self.mw.mdlLabels.rowCount()): item = self.mw.mdlLabels.item(i, 0) if item: item = QListWidgetItem(item.icon(), item.text()) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Checked) item.setSizeHint(QSize(100, h)) self.lstContentLabels.addItem(item) self.chkContentLabels.toggled.connect(self.lstContentLabels.setVisible) self.chkContentLabels.toggled.connect(lambda: self.listWidgetAdjustToContent(self.lstContentLabels)) self.lstContentLabels.setVisible(False) # Status self.lstContentStatus.clear() h = QFontMetrics(self.font()).height() for i in range(0, self.mw.mdlStatus.rowCount()): item = self.mw.mdlStatus.item(i, 0) if item: item = QListWidgetItem(item.icon(), item.text()) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Checked) item.setSizeHint(QSize(100, h)) self.lstContentStatus.addItem(item) self.chkContentStatus.toggled.connect(self.lstContentStatus.setVisible) self.chkContentStatus.toggled.connect(lambda: self.listWidgetAdjustToContent(self.lstContentStatus)) self.lstContentStatus.setVisible(False) # Root item self.cmbContentParent.setModel(self.mw.mdlOutline) v = QTreeView() self.cmbContentParent.setView(v) v.setHeaderHidden(True) for i in range(1, self.mw.mdlOutline.columnCount()): v.hideColumn(i) self.chkContentParent.toggled.connect(self.cmbContentParent.setVisible) self.cmbContentParent.hide() ################################################################# # Separations for cmb in [self.cmbSepFF, self.cmbSepTT, self.cmbSepFT, self.cmbSepTF]: cmb.clear() cmb.addItem(self.tr("Empty line"), "empty") cmb.addItem(self.tr("Custom"), "custom") cmb.currentIndexChanged.connect(self.sepCmbChanged) ################################################################# # Transformations h = self.tblReplacements.horizontalHeader() h.setSectionResizeMode(h.ResizeToContents) h.setSectionResizeMode(1, h.Stretch) h.setSectionResizeMode(2, h.Stretch) # Cf. https://en.wikipedia.org/wiki/Quotation_mark self.cmbTransDoubleQuotes.clear() self.cmbTransDoubleQuotes.addItems(["”___“", "“___”", "«___»"]) self.cmbTransSingleQuote.clear() self.cmbTransSingleQuote.addItems(["‘___’", "‹___›"]) for cmb in [self.cmbTransDoubleQuotes, self.cmbTransSingleQuote]: cmb.addItem(self.tr("Custom"), "custom") cmb.currentIndexChanged.connect(self.transCmbChanged) cmb.currentIndexChanged.emit(0) self.btnTransAdd.clicked.connect(lambda: self.transAddTableRow(checked=True)) self.btnTransRemove.clicked.connect(self.transRemoveTableRow) self.tableWidgetAdjustToContent(self.tblReplacements) ################################################################# # Preview self.cmbPreviewFont.setCurrentFont(self.font()) self.spnPreviewSize.setValue(self.font().pointSize()) ################################################################# # Final stuff self.toolBox.setCurrentIndex(0)
def init_with_config(self, config: dict): self.screens_config = config # Set Title title = str(config['main']['name']) self.setWindowTitle(title) # Set window flag flags = Qt.CustomizeWindowHint # Small Frame # flags = Qt.FramelessWindowHint # No Frame self.setWindowFlags(flags) # Set Resolution ###################################################### # via config window_width = config['main']["resolution"][0] window_height = config['main']["resolution"][1] # via given screen geometry # window_width = self.resolution.width() # window_height = self.resolution.height() # Set Resolution End ################################################## button_width = config['main']["button-size"][0] button_height = config['main']["button-size"][1] front_color = config['main']["front_color"] background_color = config['main']["background_color"] font = config['main']["font"] self.number_of_subs = len(config['sub']) self.gui_element_builder.set_font(font) self.setFixedSize(window_width, window_height) self.main_widget.setLayout(self.main_layout) self.main_widget.setStyleSheet("background-color:" + background_color) vbox_menu = QVBoxLayout() vbox_menu.setSizeConstraint(QLayout.SetFixedSize) vbox_menu.addWidget( self.gui_element_builder.get_svg_widget(Gui_Element.TOP_LEFT_SHORT, 100, 191, front_color)) button_list_widget = QListWidget() vbox_menu.addWidget(button_list_widget) vbox_menu.addWidget( self.gui_element_builder.get_svg_widget( Gui_Element.BOTTOM_LEFT_SHORT, 100, 191, front_color)) # Header ################################################################# self.main_layout.addWidget( self.gui_element_builder.get_svg_widget(Gui_Element.BUTTON, 33, 712, front_color), 0, 1, 1, 1, Qt.AlignTop) self.main_layout.addWidget( self.gui_element_builder.get_svg_widget(Gui_Element.BUTTON, 33, 52, front_color), 0, 3, Qt.AlignTop) self.main_layout.addWidget( self.gui_element_builder.get_svg_widget(Gui_Element.END_RIGHT, 33, 33, front_color), 0, 4, Qt.AlignTop) # Header - END ########################################################### # Menu self.main_layout.addLayout(vbox_menu, 0, 0, 4, 1) # Central Window self.main_layout.addWidget(self.subscreen_stacked_widget, 1, 1, 2, 4) # Footer ################################################################# self.main_layout.addWidget( self.gui_element_builder.get_svg_widget(Gui_Element.BUTTON, 33, 712, front_color), 3, 1, Qt.AlignBottom) # Add Exit Button exit_button = QPushButton("EXIT") exit_button.setFont(QFont(font, 20, QFont.Bold)) exit_button.setFixedSize(52, 33) exit_button.setStyleSheet("background:#ff0000; border:1px solid " + front_color + ";") exit_button.clicked.connect(lambda state: self.close()) self.main_layout.addWidget(exit_button, 3, 3, Qt.AlignBottom) self.main_layout.addWidget( self.gui_element_builder.get_svg_widget(Gui_Element.END_RIGHT, 33, 33, front_color, font), 3, 4, Qt.AlignBottom) # Footer - END ########################################################### # button_ListWidget.setVerticalScrolllayout(QAbstractItemView.ScrollMode.ScrollPerItem) button_list_widget.setStyleSheet("QListWidget{background:" + background_color + "; border: 0px solid " + front_color + ";}") # Erstellen der linken Button-Leiste ############## button_width = button_width * window_width / 100 button_height = button_height * window_height / 100 button_size = QSize(button_width, button_height) for i in range(0, self.number_of_subs): sub_button_list_item = QListWidgetItem(button_list_widget) placeholder_list_item = QListWidgetItem(button_list_widget) placeholder_list_item.setSizeHint(QSize(button_width, 4)) placeholder_list_item.setBackground(QColor(background_color)) flag = placeholder_list_item.flags() & Qt.ItemIsUserCheckable placeholder_list_item.setFlags(flag) # Widgets ################################################################################################## self.subscreen_stacked_widget.insertWidget( i, self.gui_subscreen_builder.init_with_config( self.screens_config['sub'][i], self.alarm_observer)) # Buttons ################################################################################################## self.gui_button_builder.set_color( self.screens_config['sub'][i]["Background"]) self.gui_button_builder.set_size(button_height, button_width) self.button[i] = self.gui_button_builder.create_button( self.screens_config["sub"][i]["name"], Gui_Element.BUTTON_TEXT) sub_button_list_item.setSizeHint(button_size) button_list_widget.addItem(placeholder_list_item) button_list_widget.addItem(sub_button_list_item) button_list_widget.setItemWidget(sub_button_list_item, self.button[i]) # signals ################################################################################################## self.button[i].clicked.connect( lambda widget=self.subscreen_stacked_widget.widget( i): self.set_current_subscreen()) # button_list_widget.setMaximumWidth(1000) button_list_widget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) button_list_widget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) button_list_widget.setMaximumWidth( button_list_widget.sizeHintForColumn(0)) ############################################# self.subscreen_stacked_widget.setCurrentIndex(0) self.main_stack_widget.insertWidget(0, self.main_widget) self.main_stack_widget.insertWidget(1, self.alarm_widget) self.main_stack_widget.setCurrentIndex(0) self.setCentralWidget(self.main_stack_widget)
def insert_action_item_in_list(self, s, grid): lit = QListWidgetItem(s, self.acts) lit.setFlags(lit.flags() | Qt.ItemIsUserCheckable) lit.setData(Qt.UserRole, grid) lit.setCheckState(False) self.canv.setItemIcon(lit)
def __init__(self, controller): super(CocomoView, self).__init__() self.setWindowTitle('Modelo COCOMO') self.show() self.controller = controller self.formGroupBox = self.forma_grado_tot_influencia() self.forma_fae() self.forma_detalles_sistema() self.modelo_groupbox = self.crear_seleccion_modelo() self.tipo_groupbox = self.crear_seleccion_tipo() self.mainLayout = QVBoxLayout() self.secondary_bottom = QHBoxLayout() self.lenguajes_programacion_proyecto_listwidget = QListWidget() # self.lenguajes_programacion_proyecto_listwidget.state for key in Cocomo.indice_loc: item = QListWidgetItem( key, self.lenguajes_programacion_proyecto_listwidget) # item = QListWidgetItem() # item.setText(key) item.setFlags(item.flags() | Qt.ItemIsUserCheckable) item.setCheckState(Qt.Unchecked) # self.lenguajes_programacion_proyecto_listwidget.addItem(item) self.lenguajes_programacion_proyecto_listwidget.itemChanged.connect( self.definir_lenguaje_programacion) self.secondary_bottom.addWidget( self.lenguajes_programacion_proyecto_listwidget) self.secondary_bottom.addWidget(self.formGroupBox) self.secondary_bottom.addWidget(self.formGroupBox2) self.results_group = QVBoxLayout() self.results_group.addWidget(QLabel("Resultados")) self.results_group.addWidget(QLabel("Esfuerzo (persona x mes)")) self.esfuerzo_label = QLabel("0") self.results_group.addWidget(self.esfuerzo_label) self.results_group.addWidget(QLabel("Tiempo de desarrollo (meses)")) self.tiempo_desarrollo_label = QLabel("0") self.results_group.addWidget(self.tiempo_desarrollo_label) self.personal_label=QLabel("0") self.results_group.addWidget(QLabel("Personal")) self.results_group.addWidget(self.personal_label) self.results_group.addWidget(QLabel("PR(LDC/persona x mes)")) self.pr_label = QLabel("0") self.results_group.addWidget(self.pr_label) self.results_group.addWidget(QLabel("KLDC")) self.kloc_label = QLabel("0") self.results_group.addWidget(self.kloc_label) self.pf_label = QLabel("0") self.results_group.addWidget(QLabel("PF")) self.results_group.addWidget(self.pf_label) self.di_label = QLabel("0") self.results_group.addWidget(QLabel("Di")) self.results_group.addWidget(self.di_label) self.secondary_top = QHBoxLayout() self.secondary_top.addWidget(self.formGroupBox3) self.secondary_top.addWidget(self.tipo_groupbox) self.secondary_top.addWidget(self.modelo_groupbox) self.secondary_top.addLayout(self.results_group) self.mainLayout.addLayout(self.secondary_top) self.mainLayout.addLayout(self.secondary_bottom) self.button_row = QHBoxLayout() self.reset_button = QPushButton("Reestablecer", self) self.reset_button.clicked.connect(self.reset) self.button_row.addWidget(self.reset_button) self.load_button = QPushButton("Cargar", self) self.load_button.clicked.connect(self.abrir) self.button_row.addWidget(self.load_button) self.save_button = QPushButton("Salvar", self) self.save_button.clicked.connect(self.salvar) self.button_row.addWidget(self.save_button) self.mainLayout.addLayout(self.button_row) self.setLayout(self.mainLayout)
def __init__(self, browser, parent=None): """ Constructor @param browser reference to the browser window (HelpBrowser) @param parent reference to the parent widget (QWidget) """ super(SiteInfoDialog, self).__init__(parent) self.setupUi(self) self.setWindowFlags(Qt.Window) # put icons self.tabWidget.setTabIcon( 0, UI.PixmapCache.getIcon("siteinfo-general.png")) self.tabWidget.setTabIcon(1, UI.PixmapCache.getIcon("siteinfo-media.png")) self.tabWidget.setTabIcon( 2, UI.PixmapCache.getIcon("siteinfo-databases.png")) if SSL: self.tabWidget.setTabIcon( 3, UI.PixmapCache.getIcon("siteinfo-security.png")) self.__mainFrame = browser.page().mainFrame() title = browser.title() sslInfo = browser.page().getSslCertificateChain() # populate General tab self.heading.setText("<b>{0}</b>".format(title)) self.siteAddressLabel.setText(self.__mainFrame.baseUrl().toString()) self.sizeLabel.setText(dataString(browser.page().totalBytes())) encoding = "" # populate Meta tags meta = self.__mainFrame.findAllElements("meta") for element in meta: content = element.attribute("content") name = element.attribute("name") if not name: name = element.attribute("http-equiv") if element.attribute("charset"): encoding = element.attribute("charset") if "charset=" in content: encoding = content[content.index("charset=") + 8:] if not content or not name: continue QTreeWidgetItem(self.tagsTree, [name, content]) for col in range(self.tagsTree.columnCount()): self.tagsTree.resizeColumnToContents(col) if not encoding: encoding = QWebSettings.globalSettings().defaultTextEncoding() self.encodingLabel.setText(encoding) # populate the Security info and the Security tab if sslInfo and \ ((qVersion() >= "5.0.0" and not sslInfo[0].isBlacklisted()) or (qVersion() < "5.0.0" and sslInfo[0].isValid())): self.securityLabel.setStyleSheet(SiteInfoDialog.okStyle) self.securityLabel.setText('<b>Connection is encrypted.</b>') if SSL: self.sslWidget.showCertificateChain(sslInfo) self.securityDetailsButton.setEnabled(True) else: self.securityDetailsButton.setEnabled(False) else: self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle) self.securityLabel.setText('<b>Connection is not encrypted.</b>') self.securityDetailsButton.setEnabled(False) self.tabWidget.setTabEnabled( self.tabWidget.indexOf(self.securityTab), False) # populate Media tab images = self.__mainFrame.findAllElements("img") for element in images: src = element.attribute("src") alt = element.attribute("alt") if src and src.startswith("data:"): continue if not alt: if src.find("/") == -1: alt = src else: pos = src.find("/") alt = src[pos + 1:] if not src or not alt: continue QTreeWidgetItem(self.imagesTree, [alt, src]) for col in range(self.imagesTree.columnCount()): self.imagesTree.resizeColumnToContents(col) if self.imagesTree.columnWidth(0) > 300: self.imagesTree.setColumnWidth(0, 300) self.imagesTree.setCurrentItem(self.imagesTree.topLevelItem(0)) self.imagesTree.setContextMenuPolicy(Qt.CustomContextMenu) self.imagesTree.customContextMenuRequested.connect( self.__imagesTreeContextMenuRequested) # populate the Databases tab databases = self.__mainFrame.securityOrigin().databases() counter = 0 for database in databases: itm = QListWidgetItem(self.databasesList) itm.setText(database.displayName()) itm.setData(Qt.UserRole, counter) counter += 1 if counter == 0: itm = QListWidgetItem(self.databasesList) itm.setText(self.tr("No databases are used by this page.")) itm.setFlags(itm.flags() & Qt.ItemIsSelectable)