Finished! The exception handling is not great, but unless you writes it wrong on purpose, it should be okay.
This commit is contained in:
parent
e68b9852a0
commit
1f47a395d4
57
egon.py
57
egon.py
|
@ -18,7 +18,7 @@ from pysqlite2 import dbapi2 as sqlite
|
|||
from qrc_resources import *
|
||||
|
||||
|
||||
__version__ = "0.0.2"
|
||||
__version__ = "0.9.0"
|
||||
|
||||
|
||||
main = None
|
||||
|
@ -121,7 +121,6 @@ class MainWindow(QMainWindow):
|
|||
self.connect(self.reading.readingDoneButton, SIGNAL("pressed()"), self.doneReading)
|
||||
self.connect(self.schedule.addScheduleButton, SIGNAL("pressed()"), self.addLesson)
|
||||
self.connect(self.schedule.deleteScheduleButton, SIGNAL("pressed()"), self.deleteLesson)
|
||||
self.connect(self.calendar, SIGNAL("selectionChanged()"), self.changeDay)
|
||||
|
||||
# The toolbars
|
||||
fileToolbar = self.addToolBar("File")
|
||||
|
@ -144,6 +143,16 @@ class MainWindow(QMainWindow):
|
|||
|
||||
# Semester
|
||||
|
||||
## Open the New dialog
|
||||
def fileNew(self):
|
||||
self.nsdlg = NewSemesterDlg()
|
||||
self.nsdlg.show()
|
||||
|
||||
## Open the Open dialog
|
||||
def fileOpen(self):
|
||||
self.osdlg = OpenSemesterDlg()
|
||||
self.osdlg.show()
|
||||
|
||||
## Return the latest semester
|
||||
def getLatestSemester(self, semesters):
|
||||
if len(semesters) == 0:
|
||||
|
@ -335,16 +344,6 @@ class MainWindow(QMainWindow):
|
|||
<p>Developer: Tiril Anette Langfeldt Rødland, tirilane@pvv.ntnu.no
|
||||
""" % (self.title, __version__, platform.python_version(), QT_VERSION_STR, PYQT_VERSION_STR, platform.system()))
|
||||
|
||||
## Open the New dialog
|
||||
def fileNew(self):
|
||||
self.nsdlg = NewSemesterDlg()
|
||||
self.nsdlg.show()
|
||||
|
||||
## Open the Open dialog
|
||||
def fileOpen(self):
|
||||
self.osdlg = OpenSemesterDlg()
|
||||
self.osdlg.show()
|
||||
|
||||
## Updates the File menu
|
||||
def updateFileMenu(self):
|
||||
self.fileMenu.clear()
|
||||
|
@ -721,6 +720,13 @@ class AssignmentDlg(QDialog):
|
|||
description = assignmentList[3]
|
||||
complete = assignmentList[4]
|
||||
|
||||
regex = QRegExp(r"[01-31].[01-12].[2000-2050] [00-23]:[00-60]")
|
||||
validator = QRegExpValidator(regex, self)
|
||||
valid = validator.validate(dateString, 16)
|
||||
if valid == QValidator.Invalid:
|
||||
regexMessage = QErrorMessage()
|
||||
regexMessage.showMessage(QString(self.trUtf8("The date is not in a correct format.")))
|
||||
|
||||
if len(dateString) <= 11:
|
||||
dateList = dateString.split('.')
|
||||
timeList = ['00', '00']
|
||||
|
@ -728,17 +734,42 @@ class AssignmentDlg(QDialog):
|
|||
dateTime = dateString.split()
|
||||
dateList = dateTime[0].split('.')
|
||||
timeList = dateTime[1].split(':')
|
||||
print dateList, timeList
|
||||
|
||||
if dateList[1] > '13':
|
||||
dateMessage = QErrorMessage()
|
||||
dateMessage.showMessage(QString(self.trUtf8("The month is not valid. Please enter a valid date.")))
|
||||
print dateList[1]
|
||||
elif dateList[0] > '31':
|
||||
dateMessage = QErrorMessage()
|
||||
dateMessage.showMessage(QString(self.trUtf8("The day is not valid. Please enter a valid date.")))
|
||||
print dateList[0]
|
||||
elif timeList[0] > '23':
|
||||
dateMessage = QErrorMessage()
|
||||
dateMessage.showMessage(QString(self.trUtf8("The hour is not valid. Please enter a valid time.")))
|
||||
print timeList[0]
|
||||
elif timeList[1] > '59':
|
||||
dateMessage = QErrorMessage()
|
||||
dateMessage.showMessage(QString(self.trUtf8("The minutes are not valid. Please enter a valid time.")))
|
||||
print timeList[1]
|
||||
else:
|
||||
try:
|
||||
date = QDate(string.atoi(dateList[2]), string.atoi(dateList[1]), string.atoi(dateList[0]))
|
||||
time = QTime(string.atoi(timeList[0]), string.atoi(timeList[1]))
|
||||
datetime = QDateTime(date, time)
|
||||
except ValueError, e:
|
||||
valueMessage = QErrorMessage()
|
||||
valueMessage.showMessage(QString(self.trUtf8("The date is not valid. Please enter a date on the DD.MM.YYYY HH:MM form.")))
|
||||
|
||||
course = getCourseFromDB(getCourseCode(courseFull))
|
||||
|
||||
try:
|
||||
global semester
|
||||
addNewAssignmentToDB(semester, datetime, course, number, description, complete)
|
||||
|
||||
assignment = AssignmentModel(datetime, course, number, description, complete)
|
||||
except UnboundLocalError, e:
|
||||
pass
|
||||
|
||||
table = getMain().assignment.assignmentTable
|
||||
row = table.rowCount()
|
||||
table.insertRow(row)
|
||||
|
|
Reference in New Issue