-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


Sailfish OS: c

, 24 2017 . 15:00 +
! , Sailfish OS. .


API , . Sailfish OS . Sailfsh OS , .

, , Nemo QML Plugin Contacts. . , , , , .

Nemo Sailfish OS. Nemo QML Plugin Notification Nemo QML Plugin D-Bus D-Bus.

Nemo QML Plugin Contacts QML-:

  • PeopleModel;
  • PeopleNameGroupModel;
  • PeopleVCardModel;
  • Person.

, SilicaListView, .

PeopleModel : , , , e-mail, - , . PeopleNameGroupModel , . PeopleVCardModel vCard.

Person .

, PeopleModel Person. PeopleNameGroupModel PeopleVCardModel , . .

PeopleModel :

  • firstName ;
  • lastName ;
  • favorite true, , false ;
  • avatar ;
  • contactId ;
  • phoneNumbers ;
  • emailDetails ;
  • person Person, .

, , PeopleModel , . , . Person:

  • id ;
  • firstName ;
  • lastName ;
  • middleName ;
  • companyName , ;
  • role ;
  • department , ;
  • favorite true, , false ;
  • avatar ;
  • phoneNumbers ;
  • emailDetails ;
  • addressDetails ;
  • birthday .

Nemo QML Plugin Contacts .

, . yaml- Requires nemo-qml-plugin-contacts-qt5 :

...
# Runtime dependencies which are not automatically detected
Requires:
  - sailfishsilica-qt5 >= 0.10.9
  - nemo-qml-plugin-contacts-qt5
...

, yaml- rpm/ .

QML- org.nemomobile.contacts.

import org.nemomobile.contacts 1.0

, .

PeopleModel {
    id: peopleModel
    filterType: PeopleModel.FilterAll
    requiredProperty: PeopleModel.PhoneNumberRequired
}
SilicaListView {
    anchors.fill: parent
    header: PageHeader {title: qsTr("Contacts")}
    model: peopleModel
    delegate: ListItem {
        width: parent.width
        Column {
            width: parent.width
            Label {text: firstName + " " + lastName}
            Label {text: qsTr("Phone numbers: ") + phoneNumbers.join(", ")}
        }
    }
}

PeopleModel SilicaListView. PeopleModel requiredProperty , . requiredProperty EmailAddressRequired . FilterAll, filterType, . filterType FilterFavorites FilterOnline , .

, firstName, lastName phoneNumbers. phoneNumbers , join(), .


person Person PeopleModel. , savePerson(Person person), person. , . . Person .


, Sailfish OS , , .

Nemo QML Plugin Calendar. . , Nemo QML Plugin Contacts, , , .

Nemo QML Plugin Calendar . , , , :

  • AgendaModel;
  • CalendarEvent;
  • CalendarEventModification;
  • Calendar.

AgendaModel . SilicaListView. AgendaModel : startDate endDate. , .. .

AgendaModel {
    id: agendaModel
    startDate: new Date()
    endDate: new Date(2018, 0)
}

, , , 1- 2018- .

AgendaModel CalendarEvent, . CalendarEvent :

  • displayLabel ;
  • description ;
  • startTime ;
  • endTime ;
  • allDay true, ;
  • location ;
  • color , ;
  • uniqueId .

. CalendarEventModification. , CalendarEvent, . CalendarEventModification save(), .

Calendar -, , . Calendar :

  • CalendarEventModification createNewEvent();
  • CalendarEventModification createModification(CalendarEvent event);
  • void remove(string uniqueId).

createNewEvent() CalendarEventModification, . save() . .

createModification() CalendarEventModification CalendarEvent. , CalendarEvent , .. . createModification(), . save() . , , .

remove() , id.

Calendar , . , .

Calendar.createNewEvent();
Calendar.createModification(event);
Calendar.remove(event.uniqueId);

Nemo QML Plugin Calendar yaml-, .

...
# Runtime dependencies which are not automatically detected
Requires:
  - sailfishsilica-qt5 >= 0.10.9
  - nemo-qml-plugin-calendar-qt5
...

QML- org.nemomobile.calendar.

import org.nemomobile.calendar 1.0

.

AgendaModel {
    id: agendaModel
    startDate: new Date() 
    endDate: new Date(2018, 0)
}
SilicaListView {
    anchors.fill: parent
    header: PageHeader { title: qsTr("Calendar events") }
    model: agendaModel
    delegate: ListItem {
        width: parent.width
        contentHeight: column.height
        Column {
            id: column; 
            width: parent.width
            Label { text: eventDateTimeToString(event) }
            Label { text: event.displayLabel }
            Label { text: qsTr("Location: ") + event.location }
        }
    }
}
function eventDateTimeToString(event) {
    return Qt.formatTime(event.startTime, "HH:mm") + "  " 
           + Qt.formatTime(event.endTime, "HH:mm") + "\t" 
           + Qt.formatDate(event.startTime, Qt.SystemLocaleShortDate);
}

. -, SilicaListView. , . JavaScript- eventDateTimeToString(), CalendarEvent, formatTime() formatDate() .


. . .

Dialog {
    property var eventModification
    SilicaFlickable {
        //  ValueButton   ,      .           
        TextField {
            id: eventLabelTextField
            label: qsTr("Event")
            text: eventModification.displayLabel
        } 
        //  TextField  id=locationTextField     . 
    }
    onAccepted: {
        eventModification.displayLabel = eventLabelTextField.text;
        eventModification.location = locationTextField.text;
        eventModification.save();
    }
}

eventModification CalendarEventModification. , , . . . ValueButton , , TextField . onAccepted save(), . , .


. PullDownMenu, .

PullDownMenu . , , Add new event, .

PullDownMenu {
    MenuItem {
        text: "Add new event"
        onClicked: pageStack.push(Qt.resolvedUrl("EditEventDialog.qml"), 
                                  {eventModification: Calendar.createNewEvent()})
    }
} 

onClicked, , , eventModification Calendar.createNewEvent(). , .


SilicaListView. ContextMenu Edit.

SilicaListView {
    // ...
    model: agendaModel
    delegate: ListItem {
          // ...
          menu: ContextMenu {
               MenuItem {
                   text: "Edit"
                   onClicked: pageStack.push(Qt.resolvedUrl("EditEventDialog.qml"),
                                             {eventMod: Calendar.createModification(event)})
               }
        }
    }
}

Edit . eventModification CalendarEventModifiation, createModification() Calendar. createModification() event, AgendaModel , .

. .

MenuItem {
    text: qsTr("Delete")
    onClicked: Calendar.remove(event.uniqueId)
}

Delete Calendar.remove(), , uniqueId. , .



. Sailfish OS. , , . GitHub: .

Sailfish OS Telegram .

:
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/329692/

:  

: [1] []
 

:
: 

: ( )

:

  URL