From: <jb...@us...> - 2009-10-29 04:57:57
|
Revision: 377 http://pytrainer.svn.sourceforge.net/pytrainer/?rev=377&view=rev Author: jblance Date: 2009-10-29 04:57:47 +0000 (Thu, 29 Oct 2009) Log Message: ----------- Fix to display correct sport if sports have been deleted Modified Paths: -------------- pytrainer/branches/plugins-v2/pytrainer/gui/windowrecord.py pytrainer/branches/plugins-v2/pytrainer/profile.py Modified: pytrainer/branches/plugins-v2/pytrainer/gui/windowrecord.py =================================================================== --- pytrainer/branches/plugins-v2/pytrainer/gui/windowrecord.py 2009-10-29 04:12:30 UTC (rev 376) +++ pytrainer/branches/plugins-v2/pytrainer/gui/windowrecord.py 2009-10-29 04:57:47 UTC (rev 377) @@ -48,11 +48,9 @@ "rcd_maxpace", "rcd_maxvel" ] - count = 0 self.listSport = {} for i in listSport: - self.listSport[count] = i[0] - count = count+1 + self.listSport[i[3]] = i[0] #Create dictionary using SportID as key (may be non sequential if sports have been deleted) for i in self.listSport: self.rcd_sport.insert_text(i,self.listSport[i]) self.rcd_sport.set_active(0) @@ -153,12 +151,26 @@ self.setValue("rcd_pace",values[15]) self.setValue("rcd_maxbeats",values[16]) self.rcd_title.set_text("%s"%values[10]) - self.rcd_sport.set_active(int(values[2])-1) #TODO Fix - This does not work if a sport has been deleted... + sportID = values[2] + sportPosition = self.getSportPosition(sportID) + self.rcd_sport.set_active(sportPosition) buffer = self.rcd_comments.get_buffer() start,end = buffer.get_bounds() buffer.set_text(values[8]) self.mode = "editrecord" + def getSportPosition(self, sportID): + """ + Function to determin the position in the sport array for a given sport ID + Needed as once sports are deleted there are gaps in the list... + """ + count = 0 + for key, value in self.listSport.iteritems(): + if key == sportID: + return count + count +=1 + return 0 + def on_calctime_clicked(self,widget): try: distance = self.rcd_distance.get_text() Modified: pytrainer/branches/plugins-v2/pytrainer/profile.py =================================================================== --- pytrainer/branches/plugins-v2/pytrainer/profile.py 2009-10-29 04:12:30 UTC (rev 376) +++ pytrainer/branches/plugins-v2/pytrainer/profile.py 2009-10-29 04:57:47 UTC (rev 377) @@ -130,7 +130,7 @@ connection = self.ddbb.connect() if (connection == 1): logging.debug("retrieving sports info") - return self.ddbb.select("sports","name,met,weight",None) + return self.ddbb.select("sports","name,met,weight,id_sports",None) else: return connection This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |