#------------------------------------------------------------
#------------------------------------------------------------
# Hantera biblotek
def __init__(self, parent):
QtGui.
QDialog.__init__
(self, parent
) self.ui = ManageLibary()
self.ui.setupUi(self)
self.model = manageLibaryModel(self)
self.ui.listView.setModel(self.model)
self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.validateInput)
#for i in dir(self.ui.listView):
# print i
def validateInput(self):
if self.ui.lineEdit.text() != "":
# make validator later here for
data = bibliotek(self.ui.lineEdit.text())
print self.ui.lineEdit.text()
print len(LIBARY)
self.model.addItem(data)
#------------------------------------------------------------
# Manage Libary Model
#------------------------------------------------------------
#
def __init__(self, parent):
def data(self, index, role):
if role == QtCore.Qt.DisplayRole:
return LIBARY[index.row()].name
elif role == QtCore.Qt.UserRole:
return LIBARY[index.row()]
return len(LIBARY)
def addItem(self, item):
self.
beginInsertRows(QtCore.
QModelIndex(), len
(LIBARY
), len
(LIBARY
)) LIBARY.append(item)
self.endInsertRows()
#------------------------------------------------------------
#------------------------------------------------------------
# Hantera biblotek
class manageLibary(QtGui.QDialog):
def __init__(self, parent):
QtGui.QDialog.__init__(self, parent)
self.ui = ManageLibary()
self.ui.setupUi(self)
self.model = manageLibaryModel(self)
self.ui.listView.setModel(self.model)
self.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"), self.validateInput)
#for i in dir(self.ui.listView):
# print i
def validateInput(self):
if self.ui.lineEdit.text() != "":
# make validator later here for
data = bibliotek(self.ui.lineEdit.text())
print self.ui.lineEdit.text()
print len(LIBARY)
self.model.addItem(data)
#------------------------------------------------------------
# Manage Libary Model
#------------------------------------------------------------
#
class manageLibaryModel(QtCore.QAbstractListModel):
def __init__(self, parent):
QtCore.QAbstractListModel.__init__(self, parent)
def data(self, index, role):
if role == QtCore.Qt.DisplayRole:
return LIBARY[index.row()].name
elif role == QtCore.Qt.UserRole:
return LIBARY[index.row()]
def rowCount(self, parent=QtCore.QModelIndex()):
return len(LIBARY)
def addItem(self, item):
self.beginInsertRows(QtCore.QModelIndex(), len(LIBARY), len(LIBARY))
LIBARY.append(item)
self.endInsertRows()
To copy to clipboard, switch view to plain text mode
Bookmarks