def cell_status_edited(self, combr, row, value): """ Handles selection of status combo cells. Pushes the entry in other categories and eventually updates the episode number (from non-complete to complete -> maximize status_episodes) """ # We don't move to self? if value != self.liststore[row][self.STATUS]: # Prepare data maxepisodes = self.liststore[row][self.EPISODE].split(' / ')[1] self.liststore[row][self.STATUS] = value if value == LOCAL_STATUS_DICT.get(LOCAL_STATUS_R['completed']): # We move to the comleted tab? self.liststore[row][self.PROGRESS] = 100 self.liststore[row][self.EPISODE] = \ maxepisodes + ' / ' + maxepisodes #FIXME: self.push_change_to_db(row, { 'status_episodes': int(maxepisodes), 'status_status': LOCAL_STATUS_R['completed'] }) else: # we move to another tab? self.push_change_to_db(row, { 'status_status': LOCAL_STATUS_R[value] }) # Move row MODCTL.tv[LOCAL_STATUS_R[value]].liststore.append( self.liststore[row]) del self.liststore[row]
def repopulate(self): """ Resets/Initializes data to liststore (data table) INPUT ===== - self.tv_data: the update is performed with this data """ # clear previous data self.liststore.clear() # comupte and add new data based on self.data for key, anime in self.data.items(): # Extract series title name = anime['title'] name = name.replace(''', '\'') # Extract episodes/max and construct display string if anime['episodes']: max_episodes = anime['episodes'] else: max_episodes = '-' current_episode = anime['status_episodes'] epstr = str(current_episode) + ' / ' + str(max_episodes) # Calculate progress bar progress = 0 if isinstance(max_episodes, int): try: progress = \ int(float(current_episode) / float(max_episodes) * 100) except: progress = 0 # Extract score score = anime['status_score'] # Construct row list and add it to the liststore row = [name, epstr, LOCAL_STATUS_DICT.get(self.tab_id), score, progress] self.liststore.append(row) # Store key in row position self.keylist.append(key)