Accessing a C++ dataengine from a QML plasmoid

Guillaume DE BURE guillaume.debure at gmail.com
Wed Jan 30 21:38:15 UTC 2013


Le mercredi 30 janvier 2013 22:20:13 Marco Martin a écrit :
> On Wednesday 30 January 2013, Guillaume DE BURE wrote:
> > However, I am not completely clear how to access it in QML. Userbase seems
> > to say it should be possible:
> > http://techbase.kde.org/Development/Tutorials/Plasma/QML/API#DataModel
> > 
> > So I made an attempt that looks like this, but that does not work:
> > https://projects.kde.org/projects/extragear/office/skrooge/repository/revis
> > ions/plasma-dashboard/entry/plugins/applet/account-qml/contents/ui/main.qml
> > 
> > Can anybody help me ? Thanks in advance :)
> 
> banksSource.data["Accounts"] is directly the data
> 
> for the model:
> 
> PlasmaCore.DataModel {
>     dataSource: banksSource
>     sourceFilter: "Accounts"
> }
> 
> 

Thanks Marco... However, not sure I fully understood you. Did you mean I should write it like this :


Item {
    id: mainWidget

    // Connect to our dataengine
    PlasmaCore.DataSource {
        id: banksSource
        engine: "skgdataengine"
        interval: 0
        connectedSources: ["Accounts"]
    }

    // Use a modelProxy for easy filtering / sorting
    PlasmaCore.SortFilterModel {
        id: banksModel
        sourceModel: PlasmaCore.DataModel {
            dataSource: banksSource
            sourceFilter: "Accounts"
        }
    }

    // Put all accounts in a Column
    ListView {
        anchors.fill: parent
        model: banksModel

        delegate: Text {
            text: banksSource.data["Accounts"]["type"]
        }
    }
}

If yes it doesn't seem to work either... Or am I missing something obvious ?




-- 
Skrooge, a free, Open Source, personal finances software for linux, Mac OS, Windows
http://skrooge.org


More information about the Plasma-devel mailing list