tirilane
/
egon
Archived
1
0
Fork 0

Bugfix in norwegian version.

This commit is contained in:
Tiril Anette Langfeldt Rødland 2008-08-18 16:25:37 +00:00
parent e29712856c
commit 7c6335cafe
1 changed files with 19 additions and 13 deletions

View File

@ -223,10 +223,10 @@ class MainWindow(QMainWindow):
## Delete the reading from the database and the table
def deleteReading(self):
week, course, book = self.getWeekCourseAndBook()
week, course, book, chapter = self.getWeekCourseBookAndChapter()
table, row = self.getReadingTableAndRow()
global semester
removeReadingFromDB(week, course, book)
removeReadingFromDB(week, course, book, chapter)
table.removeRow(row)
table.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents)
@ -249,7 +249,8 @@ class MainWindow(QMainWindow):
bookTitle = table.item(row, 2).text()
book = getBookWithTitleFromDB(bookTitle)
bookIsbn = book.getIsbn()
updateReadingDone(week, courseCode, bookIsbn, True)
chapter = table.item(row, 4).text()
updateReadingDone(week, courseCode, bookIsbn, chapter, True)
## Return the reading table and its current row
def getReadingTableAndRow(self):
@ -258,16 +259,18 @@ class MainWindow(QMainWindow):
return table, row
## Return the week, course and book of the current reading
def getWeekCourseAndBook(self):
def getWeekCourseBookAndChapter(self):
table, row = self.getReadingTableAndRow()
weekItem = table.item(row, 0)
courseItem = table.item(row, 1)
bookItem = table.item(row, 2)
chapterItem = table.item(row, 3)
week = (weekItem.text().toInt())[0]
courseFull = courseItem.text()
courseCode = getCourseCode(courseFull)
book = getBookWithTitleFromDB(bookItem.text())
return week, courseCode, book.getIsbn()
chapter = chapterItem.text()
return week, courseCode, book.getIsbn(), chapter
# Schedule
@ -1524,7 +1527,7 @@ def initDB():
home = os.environ['HOME']
else:
home = ""
path = home+"/.egon/egon_bm.db"
path = home+"/.egon/egon_no.db"
conn = sqlite.connect(path)
cursor = conn.cursor()
@ -1586,7 +1589,7 @@ def initReadingDB(cursor):
done BOOLEAN,
term TEXT,
year INT,
PRIMARY KEY (week, course, book)
PRIMARY KEY (week, course, book, chapter)
)
''')
@ -1717,7 +1720,7 @@ def addNewCourseToDB(code, title, short, color, books):
cursor.execute('''
INSERT INTO CourseUsesBook (courseCode, bookIsbn)
VALUES (?, ?)
''', (code, book.getIsbn()))
''', (code, book))
exitDB(conn)
@ -1955,7 +1958,7 @@ def updateAssignmentCompletion(coursecode, num, completion):
exitDB(conn)
## Update whether the specified reading is done or not
def updateReadingDone(week, coursecode, bookisbn, done):
def updateReadingDone(week, coursecode, bookisbn, chapter, done):
cursor, conn = initDB()
course = "%s" % coursecode
@ -1967,7 +1970,8 @@ def updateReadingDone(week, coursecode, bookisbn, done):
WHERE week = ?
AND course = ?
AND book = ?
''', (done, week, course, book))
AND chapter = ?
''', (done, week, course, book, chapter))
exitDB(conn)
@ -1990,11 +1994,12 @@ def removeAssignmentFromDB(coursecode, num):
exitDB(conn)
## Remove the specified reading from the database
def removeReadingFromDB(week, coursecode, bookisbn):
def removeReadingFromDB(week, coursecode, bookisbn, chapter):
cursor, conn = initDB()
course = "%s" % coursecode
book = "%s" % bookisbn
ch = "%s" % chapter
cursor.execute('''
DELETE
@ -2002,7 +2007,8 @@ def removeReadingFromDB(week, coursecode, bookisbn):
WHERE week = ?
AND course = ?
AND book = ?
''', (week, course, book))
AND chapter = ?
''', (week, course, book, ch))
exitDB(conn)
@ -2041,7 +2047,7 @@ def getCourseCode(courseFull):
## Add a new course to the list of courses
def addNewCourse(course):
courses.append(course)
addNewCourseToDB(course.getCode(), course.getTitle(), course.getShort(), course.getColor())
addNewCourseToDB(course.getCode(), course.getTitle(), course.getShort(), course.getColor(), course.getBooks())
addNewCourseString(course)
## Return the list of courses