Merge lp:~caswiddershoven/openteacher/experimental into lp:~openteachermaintainers/openteacher/3.x-prototype

Proposed by Marten de Vries
Status: Merged
Approved by: Marten de Vries
Approved revision: 72
Merged at revision: 72
Proposed branch: lp:~caswiddershoven/openteacher/experimental
Merge into: lp:~openteachermaintainers/openteacher/3.x-prototype
Diff against target: 85 lines (+35/-31)
1 file modified
openteacher.py (+35/-31)
To merge this branch: bzr merge lp:~caswiddershoven/openteacher/experimental
Reviewer Review Type Date Requested Status
Marten de Vries Approve
Review via email: mp+35410@code.launchpad.net

Description of the change

See the commit details

To post a comment you must log in.
Revision history for this message
Marten de Vries (marten-de-vries) wrote :

And after browsing the code, I mark this approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openteacher.py'
2--- openteacher.py 2010-09-13 15:50:48 +0000
3+++ openteacher.py 2010-09-14 14:17:41 +0000
4@@ -561,38 +561,42 @@
5
6 def remove(self):
7 """This method removes all the selected rows."""
8+ #Check if something is selected
9 #Get the selectionmodel of the tableView
10 selectionModel = self.ui.wordsTable.selectionModel()
11- #Get the indexes of all the selected columns
12- indexes = selectionModel.selectedIndexes()
13- #Create list for the indexes of the selected rows.
14- rows = []
15- #Loop over all indexes
16- for index in indexes:
17- #Get the row out of every index, that's the only important part.
18- row = index.row()
19- #If that rownumber isn't already in the rows-list:
20- if not row in rows:
21- #Add it to it
22- rows.append(row)
23-
24- #Now we have an unsorted list of the rownumbers which should be deleted. It are simple integers.
25-
26- #Sort the row-list (mostly it is already, but to be sure.)
27- rows = sorted(rows)
28- #Reverse the list, so the last row is deleted first. (Then the rownumbers don't shift)
29- rows.reverse()
30- #Delete every row, one by one
31- for row in rows:
32- self.wordListTableModel.removeWord(row)
33-
34- #Adjust the GUI
35- self.setUnsaved()
36- self.checkEmpty()
37-
38- #Tell the user everything went fine (well, it didn't crash :p)
39- self.statusBar().showMessage(QtCore.QCoreApplication.translate("OpenTeacher", "The word(s) are succesfully removed."))
40-
41+ if selectionModel.hasSelection():
42+ #Get the indexes of all the selected columns
43+ indexes = selectionModel.selectedIndexes()
44+ #Create list for the indexes of the selected rows.
45+ rows = []
46+ #Loop over all indexes
47+ for index in indexes:
48+ #Get the row out of every index, that's the only important part.
49+ row = index.row()
50+ #If that rownumber isn't already in the rows-list:
51+ if not row in rows:
52+ #Add it to it
53+ rows.append(row)
54+
55+ #Now we have an unsorted list of the rownumbers which should be deleted. It are simple integers.
56+
57+ #Sort the row-list (mostly it is already, but to be sure.)
58+ rows = sorted(rows)
59+ #Reverse the list, so the last row is deleted first. (Then the rownumbers don't shift)
60+ rows.reverse()
61+ #Delete every row, one by one
62+ for row in rows:
63+ self.wordListTableModel.removeWord(row)
64+
65+ #Adjust the GUI
66+ self.setUnsaved()
67+ self.checkEmpty()
68+
69+ #Tell the user everything went fine (well, it didn't crash :p)
70+ self.statusBar().showMessage(QtCore.QCoreApplication.translate("OpenTeacher", "The word(s) are succesfully removed."))
71+
72+ else:
73+ self.statusBar().showMessage(QtCore.QCoreApplication.translate("OpenTeacher", "No selection was detected."))
74 ################### END Methods about entering words
75 ################### Methods about change-checking
76 def setUnsaved(self):
77@@ -1286,7 +1290,7 @@
78 #Get the current wordList
79 wordList = self.currentWordList
80 #Create a plain text document, because that's what we're doing: printing == printing the wordList exported as .txt.
81- textContent = fileTypes.TextFile()
82+ textContent = fileTypes.TextFile(None)
83
84 #Set the wordList
85 textContent.wordList = wordList

Subscribers

People subscribed via source and target branches