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