Code examples for qml-friends

All the dependencies can be installed from ppa:super-friends/ppa

Installing the qtdeclarative5-friends-plugin package should bring in the necessary dependencies

/* Sending 
   http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/poster.qml  */
   
import Friends 0.1

FriendsDispatcher {
    id: friends
    // use this to check if the send was successfull
    onSendComplete: {
         if (success) {
             console.log ("Send completed successfully");
         } else {
             console.log ("Send failed: " + errorMessage);
         }
     }
}

Button {
    id: sendButton
    text: i18n.tr("Send")
    onClicked: {
        /* async method to send, connect to onSendComplete for success/failure */
        friends.sendAsync(entry.text);
    }
}

Getting a model of the data from Friends
http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/streamview.qml

/* To get a model of all posts, suitable for use in a ListView, 
   Repeater, etc */
StreamModel {
    id: streamModel 
}

/* The roleNames provided from streamModel isn't all that intuitive right now.
    service:        column_0
    account_id:     column_1
    message_id:     column_2
    stream:         column_3
    sender:         column_4
    sender_id:      column_5
    sender_nick:    column_6
    from_me:        column_7
    timestamp:      column_8
    message:        column_9
    icon_uri:       column_10
    url:            column_11
    likes:          column_12
    liked:          column_13
    link_picture:   column_14
    link_name:      column_15
    link_url:       column_16
    link_desc:      column_17
    link_caption:   column_18
    link_icon:      column_19
    location:       column_20
    latitude:       column_21
    longitude:      column_22
*/

/* To get a model of all images */
StreamModel { 
    stream: "images"
}

/* To get a model of content from twitter */
StreamModel { 
    service: "twitter"
}

/* To get a model of content from accountId 2 */
StreamModel { 
    account: 2
}

/* To get a model of threads on a post */
StreamModel { 
    stream: "reply_to/"+messageId
}

/* convenience function for converting timestamps into time delta 
   strings, like "2 hours ago" */
FriendsUtils {
    id: friendsUtils
}

friendsUtils.createTimeString(column_8)

