标签:des style blog http color os io 使用 java
在Ubuntu平台上面,我们可以使用History API来读取电话本及短信的内容,并使用listview来显示出来。下面我们来展示该怎么做。
import Ubuntu.History 0.1
ComboButton { id: type expanded: false text: "Voice" ListView { model: typemodel delegate: ListItem.Standard { text: modelData onClicked: { console.log("item is clicked!" + index + " " + name); type.expanded = false; type.text = text; console.log("type is: " + type.text); if ( name === "Voice") { historyEventModel.type = HistoryThreadModel.EventTypeVoice; listView.model = historyEventModel } else if ( name === "Text" ) { historyEventModel.type = HistoryThreadModel.EventTypeText; listView.model = historyEventModel } else if ( name === "Thread") { listView.model = historyThreadModel } } } } }这里我们可以参考ComboButton来更加多了解如何使用这个控件。这里,我们提供了三个选项"Voice", "Text" 及“Thread"。同时我们也创建了俩个不同的history model。
HistoryEventModel { id: historyEventModel filter: HistoryFilter {} type: HistoryThreadModel.EventTypeVoice sort: HistorySort { sortField: "timestamp" sortOrder: HistorySort.DescendingOrder } } SortProxyModel { id: sortProxy sortRole: HistoryEventModel.TimestampRole sourceModel: historyEventModel ascending: false } HistoryThreadModel { id: historyThreadModel <pre name="code" class="javascript"><span style="white-space:pre"> </span>filter: HistoryFilter {}sort: HistorySort { sortField: "lastEventTimestamp" sortOrder: HistorySort.DescendingOrder } }
filter: HistoryFilter {}
ListView { id: listView width: parent.width height: parent.height - type.height Component { id: sectionDelegate Text { text: section } } model: historyEventModel delegate: ... }
怎么在Ubuntu平台上面读取电话及短信记录(History API)
标签:des style blog http color os io 使用 java
原文地址:http://blog.csdn.net/ubuntutouch/article/details/39050555