123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- import QtQuick 2.0
- import QtQuick.Controls 2.4
- import qtprotobuf.examples 1.0
- StackItem {
- id: root
- Flickable {
- anchors.fill: parent
- contentHeight: innerColumn.height + 70 + 10
- contentWidth: parent.width
- Column {
- id: innerColumn
- anchors.right: parent.right
- anchors.left: parent.left
- TextInputRow {
- id: firstNameField
- label: qsTr("First name")
- }
- TextInputRow {
- id: middleNameField
- label: qsTr("Middle name")
- }
- TextInputRow {
- id: lastNameField
- label: qsTr("Last name")
- }
- PhoneInput {
- id: homePhone
- label: qsTr("Home phone")
- PhoneNumber {
- id: _homePhoneData
- countryCode: homePhone.countryCode
- number: parseInt(homePhone.number, 10)
- }
- }
- DropDownColumn {
- anchors.right: parent.right
- anchors.left: parent.left
- width: root.width
- header: qsTr("Job")
- value: _jobTitle.text
- TextInputRow {
- id: _jobTitle
- label: qsTr("Title")
- }
- Item {
- height: 70
- anchors.right: parent.right
- anchors.left: parent.left
- PrimaryText {
- anchors.bottom: parent.bottom
- text: qsTr("Address")
- }
- }
- TextInputRow {
- id: _jstreetAddress1
- label: qsTr("Street address 1")
- }
- TextInputRow {
- id: _jstreetAddress2
- label: qsTr("Street address 2")
- }
- TextInputRow {
- id: _jzipCode
- label: qsTr("Zip code")
- }
- TextInputRow {
- id: _jstate
- label: qsTr("State")
- }
- TextInputRow {
- id: _jCountry
- label: qsTr("Country")
- }
- }
- DropDownColumn {
- anchors.right: parent.right
- anchors.left: parent.left
- width: root.width
- header: qsTr("Home address")
- TextInputRow {
- id: _streetAddress1
- label: qsTr("Street address 1")
- }
- TextInputRow {
- id: _streetAddress2
- label: qsTr("Street address 2")
- }
- TextInputRow {
- id: _zipCode
- label: qsTr("Zip code")
- }
- TextInputRow {
- id: _state
- label: qsTr("State")
- }
- TextInputRow {
- id: _country
- label: qsTr("Country")
- }
- }
- }
- }
- property Contact newContact: Contact {
- firstName: firstNameField.text
- middleName: middleNameField.text
- lastName: lastNameField.text
- job.title: _jobTitle.text
- // job.officeAddress.country: _jcountry.text
- job.officeAddress.streetAddress1: _jstreetAddress1.text
- job.officeAddress.streetAddress2: _jstreetAddress2.text
- job.officeAddress.zipCode: parseInt(_jzipCode.text, 10)
- job.officeAddress.state: _jstate.text
- // address.country: _country.text
- address.streetAddress1: _streetAddress1.text
- address.streetAddress2: _streetAddress2.text
- address.zipCode: parseInt(_zipCode.text, 10)
- address.state: _state.text
- }
- onNewContactChanged: {
- firstNameField.text = newContact.firstName
- middleNameField.text = newContact.middleName
- lastNameField.text = newContact.lastName
- _jobTitle.text = newContact.job.title
- // newContact.job.officeAddress.country: _jcountry.text
- _jstreetAddress1.text = newContact.job.officeAddress.streetAddress1
- _jstreetAddress2.text = newContact.job.officeAddress.streetAddress2
- _jzipCode.text = newContact.job.officeAddress.zipCode.toString()
- _jstate.text = newContact.job.officeAddress.state
- // newContact.address.country: _country.text
- _streetAddress1.text = newContact.address.streetAddress1
- _streetAddress2.text = newContact.address.streetAddress2
- _zipCode.text = newContact.address.zipCode.toString()
- _state.text = newContact.address.state
- var phoneNumber = newContact.phonesData.length > 0 ?
- newContact.phonesData[0] : null
- if (phoneNumber) {
- homePhone.number = phoneNumber.number.toString()
- }
- }
- FloatingRoundButton {
- id: addContactButton
- enabled: firstNameField.text.length > 0
- anchors.right: parent.right
- anchors.bottom: parent.bottom
- anchors.margins: 10
- icon: "qrc:/images/check.png"
- onClicked: {
- var phones = new Array;
- if (homePhone.number.length !== 0) {
- phones.push(_homePhoneData);
- }
- newContact.phonesData = phones;
- abEngine.addContact(newContact)
- stack.pop()
- }
- }
- }
|