def refresh_available(self): ''' Method for refreshing dialog list widget with available GooGIS layers ''' self.myDrive.configure_service() self.available_sheets = self.myDrive.list_files( orderBy=self.dlg.orderByCombo.itemData( self.dlg.orderByCombo.currentIndex())) logger("refreshing panel") try: self.dlg.listWidget.currentItemChanged.disconnect( self.viewMetadata) except: pass self.dlg.listWidget.clear() self.dlg.writeListTextBox.clear() self.dlg.readListTextBox.clear() sharedIconOwner = QIcon(os.path.join(self.plugin_dir, 'shared.png')) anyoneIconOwner = QIcon(os.path.join(self.plugin_dir, 'globe.png')) sharedIcon = QIcon(os.path.join(self.plugin_dir, 'shared_gray.png')) anyoneIcon = QIcon(os.path.join(self.plugin_dir, 'globe_gray.png')) nullIcon = QIcon(os.path.join(self.plugin_dir, 'null.png')) for sheet_name, sheet_metadata in self.available_sheets.items(): if sheet_metadata["id"] != self.myDrive.credentials.pubDbId: newItem = QListWidgetItem(QIcon(), sheet_name, self.dlg.listWidget, QListWidgetItem.UserType) if not sheet_metadata["capabilities"]["canEdit"]: font = newItem.font() font.setItalic(True) newItem.setFont(font) #if sheet in shared_sheets.keys(): permissions = self.get_permissions(sheet_metadata) owners_list = [ owner["emailAddress"] for owner in sheet_metadata['owners'] ] if 'anyone' in permissions: if self.client_id in owners_list: newItem.setIcon(anyoneIconOwner) else: newItem.setIcon(anyoneIcon) elif permissions != {}: if self.client_id in owners_list: newItem.setIcon(sharedIconOwner) else: newItem.setIcon(sharedIcon) else: newItem.setIcon(nullIcon) #newItem.setIcon(QIcon(os.path.join(self.plugin_dir,'shared.png'))) #newItem.setText(sheet) self.dlg.listWidget.addItem(newItem) self.dlg.listWidget.currentItemChanged.connect(self.viewMetadata)
def fillSourceList(self): """ Change dialog controls when an other calculation type selected. """ # get the selected stations stn1 = self.ui.Station1Combo.itemData(self.ui.Station1Combo.currentIndex()) stn2 = self.ui.Station2Combo.itemData(self.ui.Station2Combo.currentIndex()) # clear source and target list self.ui.SourceList.clear() self.ui.TargetList.clear() # get target points according to the stations targets = [] if stn1 is not None and (self.ui.OrientRadio.isChecked() or self.ui.ResectionRadio.isChecked() or self.ui.FreeRadio.isChecked()): targets = get_targets(stn1[0], stn1[1], stn1[2], True) elif stn1 is not None and self.ui.RadialRadio.isChecked(): targets = get_targets(stn1[0], stn1[1], stn1[2], False, True) elif stn1 is not None and stn2 is not None and \ self.ui.IntersectRadio.isChecked(): # fill source list for intersection (common points) targets_stn1 = get_targets(stn1[0], stn1[1], stn1[2], False) targets_stn2 = get_targets(stn2[0], stn2[1], stn2[2], False) for t1 in targets_stn1: for t2 in targets_stn2: if t1[0] == t2[0]: if not t1[0] in targets: targets.append([t1, t2]) break # fill source list widget known_list = get_known() if targets is not None: for target in targets: if self.ui.IntersectRadio.isChecked(): item = QListWidgetItem(target[0][0]) item.setData(Qt.UserRole, target) if known_list is not None and target[0][0] in known_list: itemfont = item.font() itemfont.setWeight(QFont.Bold) item.setFont(itemfont) else: item = QListWidgetItem(u"%s (id:%s)" % (target[0], target[2])) item.setData(Qt.UserRole, target) if known_list is not None and target[0] in known_list: itemfont = item.font() itemfont.setWeight(QFont.Bold) item.setFont(itemfont) self.ui.SourceList.addItem(item)
def list_compatible_canvas_layers(self): """Fill the list widget with compatible layers. :returns: Metadata of found layers. :rtype: list of dicts """ italic_font = QtGui.QFont() italic_font.setItalic(True) list_widget = self.lstCanvasAggLayers # Add compatible layers list_widget.clear() for layer in self.parent.get_compatible_canvas_layers('aggregation'): item = QListWidgetItem(layer['name'], list_widget) item.setData(QtCore.Qt.UserRole, layer['id']) if not layer['keywords']: item.setFont(italic_font) list_widget.addItem(item)
def list_compatible_canvas_layers(self): """Fill the list widget with compatible layers. :returns: Metadata of found layers. :rtype: list of dicts """ italic_font = QFont() italic_font.setItalic(True) list_widget = self.lstCanvasExpLayers # Add compatible layers list_widget.clear() for layer in self.parent.get_compatible_canvas_layers('exposure'): item = QListWidgetItem(layer['name'], list_widget) item.setData(Qt.UserRole, layer['id']) if not layer['keywords']: item.setFont(italic_font) list_widget.addItem(item)
def fillTargetList(self): """ Change Target List when an other calculation type selected. """ self.ui.TargetList.clear() self.ui.OrderList.clear() # get target points targets = get_stations(False, False) # fill target list widget known_list = get_known() if targets is not None: for target in targets: item = QListWidgetItem(u"%s (%s:%s)" % (target[0], target[1], target[2])) item.setData(Qt.UserRole, target) if known_list is not None and target[0] in known_list: itemfont = item.font() itemfont.setWeight(QFont.Bold) item.setFont(itemfont) self.ui.TargetList.addItem(item)
def __init__(self, parent, scope=None, xml_doc=None, md=None): super(MetadadoSNIMar, self).__init__(parent) if scope is None: self.scope = SCOPES.get_code_representation(md.hierarchy) else: self.scope = scope self.current_index = 0 self.widgetStalker = {} if platform.system() != "Linux": font = QFont() font.setFamily(u"Segoe UI Symbol") self.setFont(font) self.sidelist = QListWidget(self) self.sidelist.setMinimumWidth(150) self.sidelist.setMaximumWidth(150) self.sidelist.setWordWrap(True) self.sidelist.setTextElideMode(Qt.ElideNone) self.sidelist.setIconSize(QSize(25, 25)) self.sidelist.clicked.connect(self.list_clicked) index = 0 if self.scope == SCOPES.SERVICES: tabs = cons.TABLIST_SERVICES else: tabs = cons.TABLIST_CDG_SERIES for tab_element in tabs: bufWidget = QListWidgetItem( qgui.QIcon(':/resourcesFolder/icons/' + tab_element[1]), tab_element[0]) self.widgetStalker[tab_element[2]] = { "widget": bufWidget, "missingFields": set(), "incompleteEntries": set() } bufWidget.setSizeHint(QSize(150, 50)) if platform.system() != "Linux": font = QFont() font.setFamily(u"Segoe UI Symbol") bufWidget.setFont(font) self.sidelist.insertItem(index, bufWidget) index += 1 self.widgetstack = QStackedWidget(self) # Setup metadata stuff self.xml_doc = xml_doc self.is_new_file = True if xml_doc is None else False self.md = md self.codelist = self.parent().codelists self.helps = self.parent().helps self.orgs = self.parent().orgs f = open( os.path.join(pluginDirectory('EditorMetadadosMarswInforbiomares'), 'resourcesFolder/stylesheet.qtcss')) self.sytlesheet = f.read() for btn in self.findChildren(QPushButton): btn.setStyleSheet(self.sytlesheet) btn.setFocusPolicy(Qt.NoFocus) self.reference_systems_list = self.parent().reference_systems tab_list = [] # Setup snimarEditorController self.identification = snimarEditorController.IdentificationWidget( self, self.scope) tab_list.append(self.identification) if self.scope == SCOPES.SERVICES: self.operations = snimarEditorController.ServiceOperationsWidget( self) tab_list.append(self.operations) self.keywords = snimarEditorController.KeywordsWidget(self, self.scope) tab_list.append(self.keywords) self.geographicinfo = snimarEditorController.GeographicInfoWidget( self, self.scope) tab_list.append(self.geographicinfo) self.temporalinfo = snimarEditorController.TemporalInfoWidget( self, self.scope) tab_list.append(self.temporalinfo) self.quality = snimarEditorController.QualityWidget(self, self.scope) tab_list.append(self.quality) self.restrictions = snimarEditorController.RestrictionsWidget( self, self.scope) tab_list.append(self.restrictions) self.distribution = snimarEditorController.DistributionWidget( self, self.scope) tab_list.append(self.distribution) self.metadata = snimarEditorController.MetadataWidget(self) tab_list.append(self.metadata) self.setupUi() if not self.is_new_file: # Setup data self.identification.set_data(self.md) if self.scope == SCOPES.SERVICES: self.operations.set_data(md) self.temporalinfo.set_data(self.md) self.keywords.set_data(self.md) self.metadata.set_data(self.md) self.distribution.set_data(self.md) self.restrictions.set_data(self.md) self.quality.set_data(self.md) self.geographicinfo.set_data(self.md)