def removeObject(self, obj): if not obj: qWarning("PluginManagerPrivate.removeObject(): trying to remove null object") return if obj not in self.allObjects: qWarning(("PluginManagerPrivate.removeObject(): object not in list: " + obj.objectName())) return self.pluginManager.aboutToRemoveObject.emit(obj) QWriteLocker(self.pluginManager.lock) self.allObjects[:] = []
def addObject(self, obj): QWriteLocker(self.pluginManager.lock) if not obj: qWarning("PluginManagerPrivate.addObject(): trying to add None object") return if obj in self.allObjects: qWarning("PluginManagerPrivate.addObject(): trying to add duplicate object") return self.allObjects.append(obj)
def saveContact(self, name, phone, email, address): if not self.manager: qWarning("No manager selected, cannot save") return if self.contactId: print "Updating existing contact" contact = self.manager.contact(self.contactId) else: print "Creating new contact" contact = QContact() if not name: self.errorMessage = "Name must not be empty!" return False # Name if name != self.manager.synthesizedContactDisplayLabel(contact): saveNameField = self.nameField() if saveNameField: nm = QContactName(contact.detail( QContactName().DefinitionName)) nm.setValue(saveNameField, name) contact.saveDetail(nm) # Phone phoneObj = QContactPhoneNumber( contact.detail(QContactPhoneNumber.DefinitionName)) phoneObj.setNumber(phone) contact.saveDetail(phoneObj) # Email if self.emailEnabled: emailObj = QContactEmailAddress( contact.detail(QContactEmailAddress.DefinitionName)) emailObj.setEmailAddress(email) contact.saveDetail(emailObj) # Address if self.addressEnabled: addressObj = QContactAddress( contact.detail(QContactAddress.DefinitionName)) addressObj.setStreet(address) contact.saveDetail(addressObj) contact = self.manager.compatibleContact(contact) success = self.manager.saveContact(contact) if not success: qWarning("Failed to save contact") self.updateContactList() return True
def saveContact(self, name, phone, email, address): if not self.manager: qWarning("No manager selected, cannot save") return if self.contactId: print "Updating existing contact" contact = self.manager.contact(self.contactId) else: print "Creating new contact" contact = QContact() if not name: self.errorMessage = "Name must not be empty!" return False # Name if name != self.manager.synthesizedContactDisplayLabel(contact): saveNameField = self.nameField() if saveNameField: nm = QContactName(contact.detail(QContactName().DefinitionName)) nm.setValue(saveNameField, name) contact.saveDetail(nm) # Phone phoneObj = QContactPhoneNumber(contact.detail(QContactPhoneNumber.DefinitionName)) phoneObj.setNumber(phone) contact.saveDetail(phoneObj) # Email if self.emailEnabled: emailObj = QContactEmailAddress(contact.detail(QContactEmailAddress.DefinitionName)) emailObj.setEmailAddress(email) contact.saveDetail(emailObj) # Address if self.addressEnabled: addressObj = QContactAddress(contact.detail(QContactAddress.DefinitionName)) addressObj.setStreet(address) contact.saveDetail(addressObj) contact = self.manager.compatibleContact(contact) success = self.manager.saveContact(contact) if not success: qWarning("Failed to save contact") self.updateContactList() return True
def add(self, component): if component is None: return QWriteLocker(Aggregate.lock()) parent_aggregation = Aggregate.__aggregate_map().get(component) if parent_aggregation == self: return if parent_aggregation is not None: qWarning("Cannot add a component that belongs to a different aggregate: " + str(component)) return self.__components.append(component) component.destroyed.connect(self.__delete_self) Aggregate.__aggregate_map()[component] = self # K DEBUG if KDEBUG: print("parent aggregate map add component: " + component.objectName()) # self.changed.emit()
# qmlRegisterType<Person>("People", 1,0, "Person"); qmlRegisterType(Person, 'People', 1, 0, 'Person'); # QDeclarativeEngine engine; engine = QDeclarativeEngine() # QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); component = QDeclarativeComponent(engine, QUrl("example.qml")) # Person *person = qobject_cast<Person *>(component.create()); person = component.create() # if (person) { if person: # qWarning() << "The person's name is" << person->name(); # qWarning() << "They wear a" << person->shoeSize() << "sized shoe"; qWarning("The person's name is {p.name}".format(p=person)) qWarning("They wear a {p.shoeSize} sized shoe".format(p=person)) # } else { else: # usual approach failed here: needed extract all the errors from a # list, and then cast them to strings. # trying to cast to unicode resulted in an incomplete error message for x in component.errors(): qWarning(str(x)) # qWarning() << component.errors(); # qWarning(component.errors()) # return 0; # nothing equivalent here
qmlRegisterType(BirthdayParty, 'People', 1, 0, 'BirthdayParty'); # QDeclarativeEngine engine; engine = QDeclarativeEngine() # QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); component = QDeclarativeComponent(engine, QUrl("example.qml")) # BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create()); party = component.create() # if (party && party->host()) { if party and party.host: # qWarning() << party->host()->name() << "is having a birthday!"; # qWarning() << "They are inviting:"; qWarning("{host.name} is having a birthday!".format(host=party.host)) qWarning("They are inviting:") # for (int ii = 0; ii < party->guestCount(); ++ii) # qWarning() << " " << party->guest(ii)->name(); for x in range(party.guestCount()): qWarning("{}".format(party.guest(x))) # } else { else: # usual approach failed here: needed extract all the errors from a # list, and then cast them to strings. # trying to cast to unicode resulted in an incomplete error message for x in component.errors(): qWarning(str(x)) # qWarning() << component.errors(); # qWarning(component.errors())
qmlRegisterType(BirthdayParty, 'People', 1, 0, 'BirthdayParty') # QDeclarativeEngine engine; engine = QDeclarativeEngine() # QDeclarativeComponent component(&engine, QUrl("qrc:example.qml")); component = QDeclarativeComponent(engine, QUrl("example.qml")) # BirthdayParty *party = qobject_cast<BirthdayParty *>(component.create()); party = component.create() # if (party && party->host()) { if party and party.host: # qWarning() << party->host()->name() << "is having a birthday!"; # qWarning() << "They are inviting:"; qWarning("{host.name} is having a birthday!".format(host=party.host)) qWarning("They are inviting:") # for (int ii = 0; ii < party->guestCount(); ++ii) # qWarning() << " " << party->guest(ii)->name(); for x in range(party.guestCount()): qWarning("{}".format(party.guest(x))) # } else { else: # usual approach failed here: needed extract all the errors from a # list, and then cast them to strings. # trying to cast to unicode resulted in an incomplete error message for x in component.errors(): qWarning(str(x)) # qWarning() << component.errors(); # qWarning(component.errors())