(self)
| 3191 | self.sortByName2() |
| 3192 | |
| 3193 | def sortByName2(self): |
| 3194 | # find names and gid of downloads and save them in name_gid_dict |
| 3195 | # gid is key and name is value. |
| 3196 | gid_name_dict = {} |
| 3197 | for row in range(self.download_table.rowCount()): |
| 3198 | name = self.download_table.item(row, 0).text() |
| 3199 | gid = self.download_table.item(row, 8).text() |
| 3200 | gid_name_dict[gid] = name |
| 3201 | |
| 3202 | # sort names |
| 3203 | gid_sorted_list = sorted(gid_name_dict, key=gid_name_dict.get) |
| 3204 | |
| 3205 | # clear download_table and add sorted items |
| 3206 | self.download_table.clearContents() |
| 3207 | |
| 3208 | # find name of selected category |
| 3209 | current_category_tree_text = str(current_category_tree_index.data()) |
| 3210 | |
| 3211 | # get download information from data base |
| 3212 | if current_category_tree_text == 'All Downloads': |
| 3213 | downloads_dict = self.persepolis_db.returnItemsInDownloadTable() |
| 3214 | else: |
| 3215 | downloads_dict = self.persepolis_db.returnItemsInDownloadTable(current_category_tree_text) |
| 3216 | |
| 3217 | j = 0 |
| 3218 | |
| 3219 | for gid in gid_sorted_list: |
| 3220 | # enter download rows according to gid_sorted_list |
| 3221 | download_info = downloads_dict[gid] |
| 3222 | |
| 3223 | keys_list = ['file_name', |
| 3224 | 'status', |
| 3225 | 'size', |
| 3226 | 'downloaded_size', |
| 3227 | 'percent', |
| 3228 | 'connections', |
| 3229 | 'rate', |
| 3230 | 'estimate_time_left', |
| 3231 | 'gid', |
| 3232 | 'link', |
| 3233 | 'first_try_date', |
| 3234 | 'last_try_date', |
| 3235 | 'category' |
| 3236 | ] |
| 3237 | |
| 3238 | i = 0 |
| 3239 | for key in keys_list: |
| 3240 | item = QTableWidgetItem(download_info[key]) |
| 3241 | |
| 3242 | # insert item in download_table |
| 3243 | self.download_table.setItem(j, i, item) |
| 3244 | |
| 3245 | i = i + 1 |
| 3246 | |
| 3247 | j = j + 1 |
| 3248 | |
| 3249 | # save sorted list (gid_sorted_list) in data base |
| 3250 | category_dict = {'category': current_category_tree_text} |
no test coverage detected