Commit acc5d258 authored by Kevin Whitaker's avatar Kevin Whitaker

Flesh out model object and get it displaying.

parent 378eb4a7
from PySide2 import QtCore
class OTPModel(QtCore.QObject):
name=""
OTPType=""
secret=""
icon=""
_name=""
_OTPType=""
_secret=""
_icon=""
def __init__(self,name="",OTPType="",secret="",icon=""):
self.name=name
self.OTPType=OTPType
self.secret=secret
self.icon=icon
QtCore.QObject.__init__(self)
self._name=name
self._OTPType=OTPType
self._secret=secret
self._icon=icon
nameChanged = QtCore.Signal()
@QtCore.Property(str,notify=nameChanged)
def name(self):
return self._name;
@name.setter
def setName(self, name):
self._name = name
OTPTypeChanged = QtCore.Signal()
@QtCore.Property(str,notify=OTPTypeChanged)
def OTPType(self):
return self._OTPType
@OTPType.setter
def setOTPType(self, OTPType):
self._OTPType = OTPType
secretChanged = QtCore.Signal()
@QtCore.Property(str,notify=secretChanged)
def secret(self):
return self._secret
@secret.setter
def setSecret(self, secret):
self._secret = secret
iconChanged = QtCore.Signal()
@QtCore.Property(str,notify=iconChanged)
def icon(self):
return self._icon
@icon.setter
def setIcon(self,icon):
self._icon = icon
class OPTListModel(QtCore.QAbstractListModel):
......@@ -17,9 +54,22 @@ class OPTListModel(QtCore.QAbstractListModel):
def __init__(self,parent = None):
QtCore.QAbstractListModel.__init__(self, parent)
def setup(self, list):
self._items = list
def rowCount(self, parent=QtCore.QModelIndex()):
return len(self._items)
def setData(self, index, value, role):
self._items[index.row()] = value
self.dataChanged.emit(index, index)
return True
def flags(self, index):
return QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable
def data(self, index, role=QtCore.Qt.DisplayRole):
if role == QtCore.Qt.DisplayRole:
return self._items[index.row()]
else:
return None
\ No newline at end of file
......@@ -43,7 +43,7 @@ Item {
Component {
id: otpDelegate
Text {
text: "test"
text: display.name
}
}
model: otpListModel
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment