105 lines
2.6 KiB
Python
105 lines
2.6 KiB
Python
#!/usr/bin/env python
|
|
#coding: utf-8
|
|
|
|
import os
|
|
import platform
|
|
import sys
|
|
from PyQt4.QtCore import *
|
|
from PyQt4.QtGui import *
|
|
from assignment import *
|
|
from reading import *
|
|
from schedule import *
|
|
from calendar import *
|
|
#from db import *
|
|
import db
|
|
|
|
class CourseDlg(QDialog):
|
|
|
|
def __init__(self, parent=None):
|
|
super(CourseDlg, self).__init__(parent)
|
|
|
|
self.codeLabel = QLabel(self.trUtf8("&Code"))
|
|
self.titleLabel = QLabel(self.trUtf8("&Title"))
|
|
self.shortLabel = QLabel(self.trUtf8("&Short form"))
|
|
|
|
self.codeEdit = QLineEdit()
|
|
self.titleEdit = QLineEdit()
|
|
self.shortEdit = QLineEdit()
|
|
|
|
self.codeLabel.setBuddy(self.codeEdit)
|
|
self.titleLabel.setBuddy(self.titleEdit)
|
|
self.shortLabel.setBuddy(self.shortEdit)
|
|
|
|
self.layout = QGridLayout()
|
|
self.layout.addWidget(self.codeLabel, 0, 0)
|
|
self.layout.addWidget(self.titleLabel, 1, 0)
|
|
self.layout.addWidget(self.shortLabel, 2, 0)
|
|
self.layout.addWidget(self.codeEdit, 0, 1)
|
|
self.layout.addWidget(self.titleEdit, 1, 1)
|
|
self.layout.addWidget(self.shortEdit, 2, 1)
|
|
self.setLayout(self.layout)
|
|
|
|
|
|
class AddCourseDlg(CourseDlg):
|
|
|
|
def __init__(self, parent=None):
|
|
super(AddCourseDlg, self).__init__(parent)
|
|
|
|
buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
|
|
|
|
self.layout.addWidget(buttonBox, 3, 0, 1, 2)
|
|
|
|
self.connect(buttonBox, SIGNAL("accepted()"), self, SLOT("accept()"))
|
|
self.connect(buttonBox, SIGNAL("rejected()"), self, SLOT("reject()"))
|
|
|
|
self.setWindowTitle(self.trUtf8("Add new course"))
|
|
|
|
def accept(self):
|
|
courseCode = unicode(self.codeEdit.text())
|
|
courseTitle = unicode(self.titleEdit.text())
|
|
courseShort = unicode(self.shortEdit.text())
|
|
print 'code', courseCode
|
|
print 'title', courseTitle
|
|
print 'short', courseShort
|
|
course = CourseModel(courseCode, courseTitle, courseShort)
|
|
self.close()
|
|
db.addNewCourse(courseCode, courseTitle, courseShort)
|
|
|
|
|
|
class CourseModel():
|
|
|
|
code = ""
|
|
title = ""
|
|
short = ""
|
|
full = ""
|
|
|
|
def __init__(self, code, title, short):
|
|
self.code = code
|
|
self.title = title
|
|
self.short = short
|
|
self.setFull(code, title)
|
|
|
|
def setCode(self, code):
|
|
self.code = code
|
|
|
|
def getCode(self):
|
|
return self.code
|
|
|
|
def setTitle(self, title):
|
|
self.title = title
|
|
|
|
def getTitle(self):
|
|
return self.title
|
|
|
|
def setShort(self, short):
|
|
self.short = short
|
|
|
|
def getShort(self):
|
|
return self.short
|
|
|
|
def setFull(self, code, title):
|
|
self.full = code + ' ' + title
|
|
|
|
def getFull(self):
|
|
return self.full
|