Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.0
- import Sailfish.Silica 1.0
- import Sailfish.Silica.theme 1.0
- import net.khertan.python 1.0
- Page {
- id: page
- // To enable PullDownMenu, place our content in a SilicaFlickable
- SilicaFlickable {
- anchors.fill: parent
- // PullDownMenu and PushUpMenu must be declared in SilicaFlickable, SilicaListView or SilicaGridView
- PullDownMenu {
- MenuItem {
- text: "Show Page 2"
- onClicked: pageStack.push(Qt.resolvedUrl("SecondPage.qml"))
- }
- }
- // Tell SilicaFlickable the height of its content.
- contentHeight: childrenRect.height
- ListModel {
- id: notesModel
- function applyFilter(searchText) {
- pyNotes.listNotes(searchText);
- }
- function fill(data) {
- notesModel.clear();
- // Python returns a list of dicts - we can simply append
- // each dict in the list to the list model
- /*for (var i=0; i<data.length; i++) {
- notesModel.append(data[i]);
- console.debug(data[i].title);
- }*/
- console.debug('notesModel filled');
- }
- }
- Connections {
- target: pyNotes
- onMessage: {
- notesModel.fill(message)
- }
- onRequireRefresh: {
- notesModel.applyFilter()
- }
- }
- // Place our content in a Column. The PageHeader is always placed at the top
- // of the page, followed by our content.
- Component {
- id:notesViewDelegate
- BackgroundItem {
- /* Column {
- x: Theme.paddingLarge
- height: Theme.itemSizeSmall
- width: notesView.width*/
- Label {
- text: model.title
- truncationMode: TruncationMode.Fade
- //font.family: Theme.fontFamily
- //font.pixelSize: Theme.fontSizeMedium
- //font.weight: Font.Bold
- //color:Theme.primaryColor
- x: Theme.paddingLarge
- //anchors.left: parent.left
- //anchors.right: parent.right
- //elide: Text.ElideRight
- //maximumLineCount: 1
- anchors {
- left: parent.left
- rightMargin: Theme.paddingSmall
- }
- }
- /* Label {
- text: model.timestamp;
- font.family: Theme.fontFamily
- font.pixelSize: Theme.fontSizeSmall
- color: Theme.secondaryColor
- anchors.left: parent.left;
- anchors.right: parent.right
- elide: Text.ElideRight
- //maximumLineCount: 1
- }
- }*/
- onClicked: {
- console.log("Clicked " + path)
- //var editingPage = Qt.createComponent(Qt.resolvedUrl("EditPage.qml"));
- //pageStack.push(editingPage, {path: path});
- }
- }
- }
- SilicaListView {
- id: notesView
- model: notesModel
- anchors.fill: parent
- header: PageHeader {
- title: "ownNotes"
- }
- delegate: notesViewDelegate
- ViewPlaceholder {
- enabled: notesModel.count == 0
- text: "No notes."
- }
- }
- Component.onCompleted: {
- console.debug('onCompleted notesModel')
- pyNotes.listNotes('');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment