def thesaurus_info_dic(self): return { 'title': u"" + self.name + u" " + self.version, 'version': u"" + self.version, 'date': u"" + self.date, 'datetype': customCombo.CodeListItem(u"publication", u"Publicação") }
def set_data(self, name, dcpList, connectionPointList): self.operationName.setText(name) for dcp in dcpList: if self.combo_items_dcp.get(dcp) is not None: self.dcp.model().addNewRow(self.combo_items_dcp.get(dcp)) else: self.dcp.model().addNewRow(customCombo.CodeListItem(dcp, dcp, dcp)) for c in connectionPointList: self.connectionPoint.model().addNewRow(c)
def set_data(self, md): if md is None: return None if self.scope != SCOPES.SERVICES: common = md.identification else: common = md.serviceidentification if common is None: return for row in common.securityconstraints: if self.combo_items_md_classificationcode.get(row) is None: self.securityrestrictions.model().addNewRow( customCombo.CodeListItem(row, row, row)) else: self.securityrestrictions.model().addNewRow( self.combo_items_md_classificationcode[row]) for row in common.useconstraints: if self.combo_items_md_restrictionscode.get(row) is None: self.useConstraints.model().addNewRow( customCombo.CodeListItem(row, row, row)) else: self.useConstraints.model().addNewRow( self.combo_items_md_restrictionscode[row]) for row in common.accessconstraints: if self.combo_items_md_restrictionscode.get(row) is None: self.accessConstraints.model().addNewRow( customCombo.CodeListItem(row, row, row)) else: self.accessConstraints.model().addNewRow( self.combo_items_md_restrictionscode[row]) for row in common.uselimitation: if row is not None and row.strip() != "": self.useLimitation.model().addNewRow(row) for row in common.otherconstraints: if row is not None and row.strip() != "": self.otherConstraints.model().addNewRow(row)
def set_data(self, md): if md is None: return False if self.scope != SCOPES.SERVICES: if md.identification is None: return for topic in md.identification.topiccategory: if self.combo_items_topiccategory.get(topic) is not None: self.topiccategory.model().addNewRow(self.combo_items_topiccategory[topic]) elif customCombo.reverse_en_to_pt_keys(self.combo_items_topiccategory).get(topic) is not None: self.topiccategory.model().addNewRow( customCombo.reverse_en_to_pt_keys(self.combo_items_topiccategory)[topic]) else: self.topiccategory.model().addNewRow(customCombo.CodeListItem(topic, topic, topic)) common = md.identification else: common = md.serviceidentification if common is None: return for keyword in common.keywords: for word in keyword.keywords: if keyword.is_inspire() and self.scope != SCOPES.SERVICES: if self.combo_items_inspire.get(word, None) is not None: self.inspire.model().addNewRow(self.combo_items_inspire[word]) elif customCombo.reverse_en_to_pt_keys(self.combo_items_inspire).get(word, None) is not None: self.inspire.model().addNewRow( customCombo.reverse_en_to_pt_keys(self.combo_items_inspire)[word]) else: self.inspire.model().addNewRow(customCombo.CodeListItem(word, word, word)) elif keyword.is_serviceClassification() and self.scope == SCOPES.SERVICES: if self.combo_items_serviceClassification.get(word, None) is not None: self.serviceClassification.model().addNewRow(self.combo_items_serviceClassification[word]) elif customCombo.reverse_en_to_pt_keys(self.combo_items_serviceClassification).get(word, None) is not \ None: self.serviceClassification.model().addNewRow( customCombo.reverse_en_to_pt_keys(self.combo_items_serviceClassification)[word]) else: self.serviceClassification.model().addNewRow(customCombo.CodeListItem(word, word, word)) elif keyword.is_snimar(): if customCombo.reverse_pt_to_en_keys(self.combo_items_md_keywordtypecode_snimar).get( keyword.type) is None: type_ = customCombo.CodeListItem(keyword.type, keyword.type, keyword.type) else: type_ = customCombo.reverse_pt_to_en_keys(self.combo_items_md_keywordtypecode_snimar).get( keyword.type) thesaurus = { 'title': keyword.thesaurus["title"], 'version': u"v" + keyword.thesaurus["title"].split('v')[1], 'date': keyword.thesaurus['date'], 'datetype': customCombo.CodeListItem(u"publication", u"Publicação") } self.snimarkeywords.model().addNewRow( [type_, word, thesaurus['version'], thesaurus, keyword.cc_uuid]) self.snimar_keywords_special_validation() elif keyword.is_worms(): self.wormskeywords.model().addNewRow( [word, keyword.thesaurus['date']] ) elif keyword.is_crossref(): self.crossrefkeywords.model().addNewRow( [word, keyword.thesaurus['title'].split('doi:')[-1], keyword.thesaurus['date']] ) else: if customCombo.reverse_pt_to_en_keys(self.combo_items_md_keywordtypecode).get(keyword.type) is None: if keyword.type is None: type_ = None else: type_ = customCombo.CodeListItem(keyword.type, keyword.type, keyword.type) else: type_ = customCombo.reverse_pt_to_en_keys(self.combo_items_md_keywordtypecode).get(keyword.type) row = [word] + [type_] if keyword.thesaurus is not None: row.append(keyword.thesaurus['title']) date = qcore.QDate.fromString(keyword.thesaurus['date'], cons.DATE_FORMAT) row.append(date) if self.combo_items_datetype.get(keyword.thesaurus['datetype']) is None: kw_type = None else: kw_type = self.combo_items_datetype[keyword.thesaurus['datetype']] row.append(kw_type) else: row += [None] * 3 self.freekeywords.model().addNewRow(row)
def __init__(self, parent, edition_mode=True): super(ContactsDialog, self).__init__(parent) if platform.system() != "Linux": font = QFont() font.setFamily(u"Segoe UI Symbol") self.setFont(font) # VIEW SETUP############################################################# self.setupUi(self) self.superParent = self.parent() for btn in self.findChildren(qwidgets.QPushButton, qcore.QRegExp('btn_*')): if '_add_' in btn.objectName(): btn.setIcon(qgui.QIcon(':/resourcesFolder/icons/plus_icon.svg')) btn.setText('') elif '_del_' in btn.objectName(): btn.setIcon(qgui.QIcon(':/resourcesFolder/icons/delete_icon.svg')) btn.setText('') elif '_clear_' in btn.objectName(): btn.setIcon(qgui.QIcon(':/resourcesFolder/icons/delete_field.svg')) lists = ['phone', 'fax', 'email'] for item in lists: btn = self.findChild(qwidgets.QPushButton, 'btn_add_' + item) btn.clicked.connect(self.add_list_row) btn = self.findChild(qwidgets.QPushButton, 'btn_del_' + item) btn.clicked.connect(self.del_list_row) for info in self.findChildren(qwidgets.QPushButton, qcore.QRegExp('info_*')): info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg')) info.setText('') info.pressed.connect(self.printHelp) # Contact list connections and variables self.contact_array = None self.open_contact_array() self.current_contact = None self.contact_list.clearSelection() self.contactPanel.setDisabled(True) # SETUP THE DIALOG MODE if edition_mode: # EDITION MODE self.orgs = {} org = self.superParent.orgs for x in org: name = org[x] + " (" + x + ")" self.orgs[x] = cus.CodeListItem(name, name, name) self.combo_org.setModel( cus.CustomComboBoxModel(self, [cus.CodeListItem(OUTRA, OUTRA, OUTRA)] + sorted(list(self.orgs.values()), key=lambda x: x.term_pt))) self.combo_org.currentIndexChanged.connect(self.check_org) self.btn_contact_add.setVisible(True) self.btn_contact_del.setVisible(True) self.cancelChanges() self.btn_add_contact_metadata.setVisible(False) # CONNECTING FIELDS THAT CAN BE CHANGED self.name.textChanged.connect(self.changesMade) self.organization.textChanged.connect(self.changesMade) self.city.textChanged.connect(self.changesMade) self.postalcode.textChanged.connect(self.changesMade) self.country.textChanged.connect(self.changesMade) self.delivery_point.textChanged.connect(self.changesMade) self.phone.model().rowsInserted.connect(self.changesMade) self.fax.model().rowsInserted.connect(self.changesMade) self.email.model().rowsInserted.connect(self.changesMade) self.online.textChanged.connect(self.changesMade) self.phone.model().rowsRemoved.connect(self.changesMade) self.fax.model().rowsRemoved.connect(self.changesMade) self.email.model().rowsRemoved.connect(self.changesMade) self.online.textChanged.connect(self.changesMade) # SETUP MANDATORY FIELDS VISUAL VALIDATION self.organization.editingFinished.connect(self.setup_mandatory_label) self.name.editingFinished.connect(self.setup_mandatory_label) self.setup_mandatory_label() # ACTIONS SETUP self.btn_contact_save.clicked.connect(self.save_contact) # save contact self.btn_cancelClose.clicked.connect(self.cancelChanges) # cancel changes and revert contact self.btn_contact_add.clicked.connect( self.new_contact) # add new contact if changes in current contact exists ask... self.btn_contact_del.clicked.connect(self.delete_contact) # delete contact with confirmation self.contact_list.itemClicked.connect( self.selection_changed) # change current selection if changes exists ask... else: # EXPORT MODE self.contactPanel.hide() self.btn_add_contact_metadata.setVisible(True) self.btn_contact_add.setVisible(False) self.btn_contact_del.setVisible(False) self.adjustSize() # ACTIONS SETUP self.contact_list.itemClicked.connect(self.selection_changed_export_Mode) # change current selection # ACTIONS FUNCTIONS self.eater = tla.EatWheel() for x in self.findChildren(qwidgets.QComboBox): x.installEventFilter(self.eater) x.setFocusPolicy(Qt.StrongFocus) for x in self.findChildren(QDateTimeEdit): x.installEventFilter(self.eater) x.setFocusPolicy(Qt.StrongFocus)
def __init__(self, parent, orgslist, in_distribution=False): super(InlineContactWidget, self).__init__(parent) self.parent = parent self.superParent = parent.superParent self.setupUi(self) if platform.system() != "Linux": font = QFont() font.setFamily(u"Segoe UI Symbol") self.setFont(font) self.orgs = {} org = orgslist for x in org: name = org[x] + " (" + x + ")" self.orgs[x] = customCombo.CodeListItem(name, name, name) self.combo_org.setModel( customCombo.CustomComboBoxModel( self, [customCombo.CodeListItem(OUTRA, OUTRA, OUTRA)] + sorted(list(self.orgs.values()), key=lambda x: x.term_pt))) self.combo_org.currentIndexChanged.connect(self.check_org) # initialized where because if was on the spot the c++ garbage collector will destroy it and cause a error self.dialog = None tla.setupListView(self.phone, QgsFilterLineEdit, self, NoParent=True) tla.setupListView(self.email, QgsFilterLineEdit, self, NoParent=True) tla.setupListView(self.fax, QgsFilterLineEdit, self, NoParent=True) tla.setupMandatoryField(None, self.organization, self.label_organization, tla.formatTooltip(u"Elemento Obrigatório.")) tla.setupMandatoryField( None, self.email, self.label_email, tla.formatTooltip( u"Deve ser indicado pelo menos um endereço eletrónico (\'<em>email</em>\')." )) for btn in self.findChildren(qwidgets.QPushButton, qcore.QRegExp('btn_*')): if '_add_' in btn.objectName(): btn.setIcon( qgui.QIcon(':/resourcesFolder/icons/plus_icon.svg')) btn.setText('') elif '_del_' in btn.objectName(): btn.setIcon( qgui.QIcon(':/resourcesFolder/icons/delete_icon.svg')) btn.setText('') for info in self.findChildren(qwidgets.QPushButton, qcore.QRegExp('info_*')): info.setIcon(qgui.QIcon(':/resourcesFolder/icons/help_icon.svg')) info.setText('') info.pressed.connect(self.printHelp) f = open( os.path.join(pluginDirectory('EditorMetadadosMarswInforbiomares'), 'resourcesFolder/stylesheet.qtcss')) self.sytlesheet = f.read() for btn in self.findChildren(qwidgets.QPushButton): btn.setStyleSheet(self.sytlesheet) btn.setFocusPolicy(Qt.NoFocus) self.name.editingFinished.connect(self.updateTitle) self.organization.textChanged.connect(self.updateTitle) self.city.editingFinished.connect(self.updateTitle) self.country.editingFinished.connect(self.updateTitle) self.email.model().dataChanged.connect(self.updateTitle) self.btn_del_contact.clicked.connect(self.deleteContact) self.btn_contact_list.clicked.connect(self.importFromListContacts) self.btn_addto_list_contacts.clicked.connect(self.addtoListOfContacts) self.mGroupBox.collapsedStateChanged.connect(self.hideButtons) self.btn_del_contact.setToolTip(tla.formatTooltip(u"Agagar contacto.")) self.updateTitle() self.btn_addto_list_contacts.setIcon( qgui.QIcon(':/resourcesFolder/icons/save_icon.svg')) self.btn_addto_list_contacts.setToolTip( tla.formatTooltip(u"Guardar contacto na Lista de Contactos.")) self.btn_contact_list.setIcon( qgui.QIcon(':/resourcesFolder/icons/contactsList_icon.svg')) self.btn_contact_list.setToolTip(u'Importar da Lista de Contactos') self.btn_contact_list.setText('') self.btn_addto_list_contacts.setText('') self.eater = tla.EatWheel() for x in self.findChildren(qwidgets.QComboBox): x.installEventFilter(self.eater) x.setFocusPolicy(Qt.StrongFocus) for x in self.findChildren(QDateTimeEdit): x.installEventFilter(self.eater) x.setFocusPolicy(Qt.StrongFocus) for x in self.findChildren(QDateEdit): x.installEventFilter(self.eater) x.setFocusPolicy(Qt.StrongFocus) if in_distribution: temp = {} temp["distributor"] = {} temp["distributor"]["en"] = "distributor" temp["distributor"]["pt"] = "Distribuidor" temp["distributor"]["description"] = "Distribuidor" self.roles = customCombo.dic_to_CustomComboBox_dic(temp) self.combo_role.setModel( customCombo.CustomComboBoxModel( self, sorted(list(self.roles.values()), key=lambda x: x.term_pt))) self.combo_role.setDisabled(True) else: self.roles = customCombo.dic_to_CustomComboBox_dic( self.superParent.codelist["CI_RoleCode"]) self.combo_role.setModel( customCombo.CustomComboBoxModel( self, sorted(list(self.roles.values()), key=lambda x: x.term_pt))) tla.setupMandatoryField( None, self.combo_role, self.label_role, u"Tem que ser especificada uma função para o contacto.") self.combo_role.currentIndexChanged.connect( self.check_mandatory_completude)
def set_data(self, md): if md is not None: self.hierarchylevel.setCurrentIndex( self.hierarchylevel.findText( self.combo_items_md_scopecode[md.hierarchy].term_pt)) self.hierarchylevel.setDisabled(True) if self.scope == SCOPES.SERVICES: if md.serviceidentification is None: return if self.combo_item_service_type.get( md.serviceidentification.type) is not None: self.serviceType.setCurrentIndex( self.serviceType.findText(self.combo_item_service_type[ md.serviceidentification.type].term_pt)) if self.combo_items_couplingType.get( md.serviceidentification.couplingtype) is not None: self.couplingType.setCurrentIndex( self.couplingType. findText(self.combo_items_couplingType[ md.serviceidentification.couplingtype].term_pt)) for opOn in md.serviceidentification.operateson: if opOn.get('href'): self.operatesOn.model().addNewRow(opOn['href']) common = md.serviceidentification else: if md.identification is None: return for lang in md.identification.language: if self.combo_items_languagecode.get(lang) is None: self.language.model().addNewRow( customCombo.CodeListItem(lang, lang, lang)) else: self.language.model().addNewRow( self.combo_items_languagecode[lang]) if self.combo_items_md_charactersetCode.get( md.identification.charset) is None: self.characterset.setCurrentIndex( self.characterset.findText(cons.PREDEF_CHARSET)) else: self.characterset.setCurrentIndex( self.characterset.findText( self.combo_items_md_charactersetCode.get( md.identification.charset).term_pt)) for geo in md.identification.spatialrepresentation: if self.combo_items_md_spatialrepresentationtypecode.get( geo) is None: self.geographicrepresentation.model().addNewRow( customCombo.CodeListItem(geo, geo, geo)) else: self.geographicrepresentation.model().addNewRow( self. combo_items_md_spatialrepresentationtypecode[geo]) not_unk = True if len(md.identification.denominators) > 0: for val in md.identification.denominators: if int(val) == -1: self.spatiaResolutionUnknown.setChecked(True) self.equivalentscale.model().deleteAll() not_unk = False break else: try: self.equivalentscale.model().addNewRow( int(val)) except ValueError: pass # discard value if len(md.identification.distance) > 0 and not_unk: for val, uom in zip(md.identification.distance, md.identification.uom): uom = unit_decoder(uom) try: ums = self.combo_items_distance_units.get( uom, self.combo_items_distance_units.get('m')) self.distance.model().addNewRow( (float(val.replace(',', '.')), ums)) except ValueError: pass # discard value self.check_mandatory_resolution() common = md.identification ############################################33 for cred in common.credits: if cred is not None and cred.strip() != "": self.credits.model().addNewRow(cred) for res in common.resourcemaintenance: if self.combo_items_md_maintenancefrequencycode.get( res) is not None: self.resourcemaintenance.model().addNewRow( self.combo_items_md_maintenancefrequencycode[res]) else: self.resourcemaintenance.model().addNewRow( customCombo.CodeListItem(res, res, res)) self.graphicoverview.setText(common.graphicoverview) self.title.setText(common.title) self.titleEN.setText(common.titleEN) self.abstract_.setPlainText(common.abstract) self.abstractEN.setPlainText(common.abstractEN) self.alternatetitle.setText(common.alternatetitle) for status in common.status: if self.combo_items_md_progressCode.get(status) is not None: self.resourcestatus.model().addNewRow( self.combo_items_md_progressCode[status]) else: self.resourcestatus.model().addNewRow( customCombo.CodeListItem(status, status, status)) self.purpose.setPlainText(common.purpose) for index, item in enumerate(common.uricode): self.identifiers.model().addNewRow( [item, common.uricodespace[index]]) # Set contacts contact_index = 0 for contact in common.contact: self.addContact() contact_object = self.contacts_list[contact_index] contact_object.set_data(contact) contact_index += 1 self.check_mandatory_contacts()