From 378eb4a7212393457386f26303d711470036cf06 Mon Sep 17 00:00:00 2001 From: Kevin Whitaker Date: Mon, 24 Sep 2018 15:12:18 -0400 Subject: [PATCH] Starting getting list and model together. --- OTPListModel.py | 23 ++++++++++++++++++++++- app.py | 11 ++++++++++- qml/otplist.qml | 14 +++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/OTPListModel.py b/OTPListModel.py index 98d82a1..3d4e6d7 100644 --- a/OTPListModel.py +++ b/OTPListModel.py @@ -1,4 +1,25 @@ from PySide2 import QtCore +class OTPModel(QtCore.QObject): + name="" + OTPType="" + secret="" + icon="" + def __init__(self,name="",OTPType="",secret="",icon=""): + self.name=name + self.OTPType=OTPType + self.secret=secret + self.icon=icon + + class OPTListModel(QtCore.QAbstractListModel): - pass \ No newline at end of file + _items=[] + def __init__(self,parent = None): + QtCore.QAbstractListModel.__init__(self, parent) + + def rowCount(self, parent=QtCore.QModelIndex()): + return len(self._items) + + def data(self, index, role=QtCore.Qt.DisplayRole): + if role == QtCore.Qt.DisplayRole: + return None \ No newline at end of file diff --git a/app.py b/app.py index 589e964..45dc3c5 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,15 @@ from PySide2.QtQml import QQmlApplicationEngine from PySide2.QtWidgets import QApplication +import OTPListModel +import keyring +import json qapp = QApplication() -app = QQmlApplicationEngine("qml/main.qml") +app = QQmlApplicationEngine() +model = OTPListModel.OPTListModel() + +#keyring.set_password("test","boo","yeah") + +app.rootContext().setContextProperty("otpListModel", model) +app.load("qml/main.qml") qapp.exec_() diff --git a/qml/otplist.qml b/qml/otplist.qml index 355f731..980a599 100644 --- a/qml/otplist.qml +++ b/qml/otplist.qml @@ -35,6 +35,18 @@ Item { } } ListView { - id:otpList + id: otpList + anchors.top: otpTimeout.bottom + anchors.right: parent.right + anchors.left: parent.left + anchors.bottom: parent.bottom + Component { + id: otpDelegate + Text { + text: "test" + } + } + model: otpListModel + delegate: otpDelegate } } \ No newline at end of file -- GitLab