@@ -2298,12 +2298,9 @@ def get_search_results_dialog(self):
2298
2298
Button (buttonsframe , text = STR ('Save results' ), width = 14 , command = self .find_save_results ).pack (side = 'left' , anchor = 'n' ,padx = 5 ,pady = 5 )
2299
2299
Button (buttonsframe , text = STR ('Close' ), width = 14 , command = self .find_results_close ).pack (side = 'left' , anchor = 'n' ,padx = 5 ,pady = 5 )
2300
2300
2301
- self .search_results_dialog .info_label = Label (self .search_results_dialog .area_main ,text = 'info label' ,anchor = 'w' ,relief = 'ridge' )
2302
- #frame1 = LabelFrame(self.search_results_dialog.area_main,text='Info',bd=2,bg=self.bg_color,takefocus=False)
2301
+ self .search_results_dialog .info_label = Label (self .search_results_dialog .area_main ,text = '' ,anchor = 'w' ,relief = 'ridge' )
2303
2302
self .search_results_dialog .info_label .grid (row = 1 ,column = 0 ,sticky = 'news' ,padx = 4 ,pady = (4 ,2 ))
2304
2303
2305
- #self.search_results_dialog.info_label.pack(fill='both',expand=1)
2306
-
2307
2304
self .search_results_dialog .area_main .grid_rowconfigure (0 , weight = 1 )
2308
2305
2309
2306
self .search_results_dialog_created = True
@@ -2916,8 +2913,9 @@ def settings_show(self):
2916
2913
2917
2914
def finder_wrapper_show (self ,from_main = True ):
2918
2915
if librer_core .records :
2919
- if self .any_valid_find_results and from_main :
2920
- self .find_show_results_core (self .find_results_info )
2916
+
2917
+ if self .any_valid_find_results and from_main and self .all_records_find_results_can_show :
2918
+ self .find_show_results_core ()
2921
2919
else :
2922
2920
self .finder_wrapper_show_finder ()
2923
2921
@@ -3025,48 +3023,42 @@ def find_save_results(self):
3025
3023
3026
3024
self .status ('file saved: "%s"' % str (report_file_name ))
3027
3025
3028
- def find_show_results (self ,results_info = None ):
3029
- self .find_close ()
3030
- self .find_show_results_core (results_info = None )
3031
-
3032
- @block
3033
- def find_show_results_core (self ,results_info = None ):
3034
- results_quant = sum ([len (record .find_results ) for record in librer_core .records ])
3035
-
3036
- if results_quant > 100000 :
3026
+ def find_show_results (self ):
3027
+ if not self .all_records_find_results_can_show :
3037
3028
self .results_on_find .show ('Search results' ,'Number of items exceeded 100 000.' )
3038
- elif results_quant == 0 :
3039
- self .results_on_find .show ('Search results' ,'No results matching search criteria.' )
3040
3029
else :
3041
- results_dialog = self .get_search_results_dialog ()
3042
- children = self .results_tree .get_children ()
3043
- self .results_tree .delete (* children )
3044
- self .found_item_to_data = {}
3030
+ self .find_close ()
3031
+ self .find_show_results_core ()
3045
3032
3046
- for record in librer_core .records :
3047
- if record .find_results :
3048
- record_name = librer_core .get_record_name (record )
3049
- record_node = self .results_tree .insert ('' ,'end' ,text = record_name ,values = (len (record .find_results ),'' ))
3033
+ @block
3034
+ def find_show_results_core (self ):
3035
+ results_dialog = self .get_search_results_dialog ()
3036
+ children = self .results_tree .get_children ()
3037
+ self .results_tree .delete (* children )
3038
+ self .found_item_to_data = {}
3039
+
3040
+ for record in librer_core .records :
3041
+ if record .find_results :
3042
+ record_name = librer_core .get_record_name (record )
3043
+ record_node = self .results_tree .insert ('' ,'end' ,text = record_name ,values = (len (record .find_results ),'' ))
3050
3044
3051
- if self .cfg .get (CFG_KEY_expand_search_results ):
3052
- self .results_tree .item (record_node ,open = True )
3045
+ if self .cfg .get (CFG_KEY_expand_search_results ):
3046
+ self .results_tree .item (record_node ,open = True )
3053
3047
3054
- for res_item ,res_size ,res_mtime in record .find_results :
3055
- item = self .results_tree .insert (record_node ,'end' ,text = sep .join (res_item ),values = (bytes_to_str (res_size ),strftime ('%Y/%m/%d %H:%M:%S' ,localtime_catched (res_mtime ))))
3056
- self .found_item_to_data [item ]= (record ,res_item )
3048
+ for res_item ,res_size ,res_mtime in record .find_results :
3049
+ item = self .results_tree .insert (record_node ,'end' ,text = sep .join (res_item ),values = (bytes_to_str (res_size ),strftime ('%Y/%m/%d %H:%M:%S' ,localtime_catched (res_mtime ))))
3050
+ self .found_item_to_data [item ]= (record ,res_item )
3057
3051
3058
- children = self .results_tree .get_children ()
3052
+ children = self .results_tree .get_children ()
3059
3053
3060
- if children :
3061
- first_item = children [0 ]
3062
- self .results_tree .focus_set ()
3063
- self .results_tree .selection_set (first_item )
3054
+ if children :
3055
+ first_item = children [0 ]
3056
+ self .results_tree .focus_set ()
3057
+ self .results_tree .selection_set (first_item )
3064
3058
3065
- if results_info :
3066
- results_dialog .info_label .configure (text = results_info )
3059
+ results_dialog .info_label .configure (text = self .find_results_info )
3067
3060
3068
- #self.find_close()
3069
- results_dialog .show ()
3061
+ results_dialog .show ()
3070
3062
3071
3063
def find_mod_keypress (self ,event ):
3072
3064
key = event .keysym
@@ -3259,6 +3251,10 @@ def get_selected_records(self):
3259
3251
3260
3252
return ()
3261
3253
3254
+ all_records_find_results_sum = 0
3255
+ all_records_find_results_can_show = False
3256
+ find_results_info = ''
3257
+
3262
3258
#@restore_status_line
3263
3259
def find_items (self ):
3264
3260
if self .find_params_changed :
@@ -3548,68 +3544,61 @@ def find_items(self):
3548
3544
#gc_collect()
3549
3545
#gc_enable()
3550
3546
3551
- find_results_quant_sum = 0
3552
-
3553
3547
colname ,sort_index ,is_numeric ,reverse ,group_code ,dir_code ,non_dir_code = self .column_sort_last_params
3554
3548
#print('\npre sort info colname:',colname,'is_numeric',is_numeric,'reverse:',reverse)
3555
3549
colname_real = self .REAL_SORT_COLUMN [colname ]
3556
3550
#print('colname_real:',colname_real)
3557
3551
3558
- for record in librer_core .records :
3559
- find_results_quant_sum += len (record .find_results )
3560
-
3561
- record .find_items_sort (colname_real ,reverse )
3562
- #print(record.find_result)
3563
-
3564
- self .any_valid_find_results = bool (find_results_quant_sum > 0 )
3565
-
3566
- abort_info = '\n ' + STR ('Searching aborted. Results may be incomplete.' ) if self .action_abort else ''
3567
-
3568
- self .all_records_find_results_len = find_results_quant_sum
3569
- find_results_quant_sum_format = fnumber (find_results_quant_sum )
3570
-
3571
- self .set_found ()
3572
-
3573
3552
if self .action_abort :
3553
+ self .all_records_find_results_sum = 0
3554
+ self .any_valid_find_results = 0
3555
+ self .all_records_find_results_can_show = False
3556
+ self .find_results_info = 'Aborted'
3557
+
3558
+ self .results_on_find .show (STR ('Aborted' ),STR ('Searching aborted.' ))
3574
3559
self .searching_aborted = True
3575
3560
else :
3576
- self .searching_aborted = False
3577
-
3578
- self .find_mod ()
3561
+ self .all_records_find_results_sum = sum ([len (record .find_results ) for record in librer_core .records ])
3562
+ self .any_valid_find_results = bool (self .all_records_find_results_sum > 0 )
3563
+ self .all_records_find_results_can_show = bool (self .all_records_find_results_sum < 100000 )
3564
+ find_results_quant_sum_format = fnumber (self .all_records_find_results_sum )
3579
3565
3580
- search_info = '\n ' .join (self .search_info_lines )
3566
+ for record in librer_core .records :
3567
+ record .find_items_sort (colname_real ,reverse )
3581
3568
3582
- select_found = self .cfg .get (CFG_KEY_select_found )
3583
- if select_found :
3584
- if self .any_valid_find_results :
3585
- self .select_find_result (1 )
3569
+ self .searching_aborted = False
3570
+ #abort_info = '\n' + STR('Searching aborted. Results may be incomplete.') if self.action_abort else ''
3571
+ #abort_info = '\n' + STR('Searching aborted.') if self.action_abort else ''
3586
3572
3587
- #self.find_results_info = f"{search_info}\n" + STR("found") + ": " + str(find_results_quant_sum_format) + ' ' + STR('items') + '.\n' + abort_info
3588
- self .find_results_info = str (find_results_quant_sum_format ) + ' ' + STR ('items' ) + ' ' + STR ('found' ) + abort_info
3589
- #STR("Navigate search results by\n\'Find next (F3)\' & 'Find prev (Shift+F3)'\nactions.")
3573
+ self .set_found ()
3590
3574
3591
- #self.results_on_find.show(STR('Search results'),f"{search_info}\n\n" + STR("found") + ": " + str(find_results_quant_sum_format) + ' ' + STR('items') + '.\n\n' + STR("Navigate search results by\n\'Find next (F3)\' & 'Find prev (Shift+F3)'\nactions.") + abort_info)
3592
- self .status_find_tooltip (f"available search results: { find_results_quant_sum_format } " )
3575
+ self .find_mod ()
3593
3576
3594
- if not self .searching_aborted and self .any_valid_find_results :
3595
- self .search_show_butt .configure (state = 'normal' )
3596
- self .search_save_butt .configure (state = 'normal' )
3577
+ search_info = '\n ' .join (self .search_info_lines )
3597
3578
3598
- self .search_butt .configure (state = 'disabled' )
3579
+ select_found = self .cfg .get (CFG_KEY_select_found )
3580
+ if select_found :
3581
+ if self .any_valid_find_results :
3582
+ self .select_find_result (1 )
3599
3583
3600
- self .external_find_params_change = False
3584
+ #self.find_results_info = f"{search_info}\n" + STR("found") + ": " + str(find_results_quant_sum_format) + ' ' + STR('items') + '.\n' + abort_info
3585
+ self .find_results_info = str (find_results_quant_sum_format ) + ' ' + STR ('items' ) + ' ' + STR ('found' )
3586
+ # + abort_info
3587
+ #STR("Navigate search results by\n\'Find next (F3)\' & 'Find prev (Shift+F3)'\nactions.")
3601
3588
3589
+ #self.results_on_find.show(STR('Search results'),f"{search_info}\n\n" + STR("found") + ": " + str(find_results_quant_sum_format) + ' ' + STR('items') + '.\n\n' + STR("Navigate search results by\n\'Find next (F3)\' & 'Find prev (Shift+F3)'\nactions.") + abort_info)
3590
+ self .status_find_tooltip (f"available search results: { find_results_quant_sum_format } " )
3602
3591
3603
- #self.find_dialog.hide()
3592
+ if not self .searching_aborted and self .all_records_find_results_sum == 0 :
3593
+ self .results_on_find .show ('Search results' ,'No results matching search criteria.' )
3604
3594
3605
- #if self.any_valid_find_results:
3595
+ if not self .searching_aborted and self .any_valid_find_results :
3596
+ self .search_show_butt .configure (state = 'normal' )
3597
+ self .search_save_butt .configure (state = 'normal' )
3606
3598
3607
- #if self.results_on_find.res_bool:
3608
- # self.find_dialog.hide()
3599
+ self .search_butt .configure (state = 'disabled' )
3609
3600
3610
- # if find_results_quant_sum_format:
3611
- # self.find_result_index=-1
3612
- # self.find_next()
3601
+ self .external_find_params_change = False
3613
3602
else :
3614
3603
self .info_dialog_on_find .show (STR ('Search aborted.' ),'Same params' )
3615
3604
@@ -3666,7 +3655,7 @@ def select_find_result(self,mod,record_par=None,subpath_list_par=None):
3666
3655
continue
3667
3656
else :
3668
3657
settled = True
3669
- status_to_set = f'record find result: { fnumber (self .find_result_index + 1 if self .find_result_index >= 0 else record_find_results_len + self .find_result_index + 1 )} / { fnumber (record_find_results_len )} / { fnumber (self .all_records_find_results_len )} '
3658
+ status_to_set = f'record find result: { fnumber (self .find_result_index + 1 if self .find_result_index >= 0 else record_find_results_len + self .find_result_index + 1 )} / { fnumber (record_find_results_len )} / { fnumber (self .all_records_find_results_sum )} '
3670
3659
3671
3660
record_item = self .record_to_item [record ]
3672
3661
0 commit comments