116
116
CFG_geometry = 'geometry'
117
117
CFG_geometry_search = 'geometry_search'
118
118
CFG_SORTING = 'sorting'
119
+ CFG_SORTING_RESULTS = 'sorting_results'
119
120
CFG_KEY_show_popups = 'show_popups'
120
121
CFG_KEY_groups_collapse = 'groups_collapse'
121
122
CFG_KEY_include_hidden = 'include_hidden'
@@ -784,10 +785,22 @@ def help_cascade_post():
784
785
self .column_sort_last_params = self .cfg_get (CFG_SORTING )
785
786
if len (self .column_sort_last_params )!= 7 :
786
787
raise
788
+
787
789
except :
788
790
#colname,sort_index,is_numeric,reverse,group_code,dir_code,non_dir_code
789
791
self .column_sort_last_params = ('#0' ,self_REAL_SORT_COLUMN_INDEX ['#0' ],self_REAL_SORT_COLUMN_IS_NUMERIC ['#0' ],0 ,0 ,1 ,2 )
790
792
793
+ try :
794
+ self .column_sort_last_params_results = self .cfg_get (CFG_SORTING_RESULTS )
795
+ if len (self .column_sort_last_params_results )!= 7 :
796
+ raise
797
+
798
+ except :
799
+ #colname,sort_index,is_numeric,reverse,group_code,dir_code,non_dir_code
800
+ self .column_sort_last_params_results = ('#0' ,self_REAL_SORT_COLUMN_INDEX ['#0' ],self_REAL_SORT_COLUMN_IS_NUMERIC ['#0' ],0 ,0 ,1 ,2 )
801
+ #self.column_sort_last_params_results=('#0',self_REAL_SORT_COLUMN_INDEX_RESULTS['#0'],self_REAL_SORT_COLUMN_IS_NUMERIC['#0'],0,0,1,2)
802
+
803
+
791
804
#######################################################################
792
805
793
806
self .main_update ()
@@ -2288,8 +2301,11 @@ def get_search_results_dialog(self):
2288
2301
results_tree = self .results_tree = Treeview (treeframe ,takefocus = True ,show = ('tree' ,'headings' ) )
2289
2302
results_tree .pack (side = 'left' ,fill = 'both' ,expand = 1 )
2290
2303
2291
- results_tree ["columns" ]= ('size_h' ,'ctime_h' )
2304
+ results_tree ["columns" ]= ('data' , 'size' , ' size_h' , 'ctime ' ,'ctime_h' )
2292
2305
results_tree ["displaycolumns" ]= ('size_h' ,'ctime_h' )
2306
+
2307
+ #results_tree["columns"]=('data','record','opened','path','size','size_h','ctime','ctime_h','kind')
2308
+
2293
2309
results_tree .heading ('#0' ,text = STR ('Name' ),anchor = 'n' )
2294
2310
results_tree .heading ('size_h' ,text = STR ('Size' ),anchor = 'n' )
2295
2311
results_tree .heading ('ctime_h' ,text = STR ('Time' ),anchor = 'n' )
@@ -2299,9 +2315,15 @@ def get_search_results_dialog(self):
2299
2315
results_tree .column ('size_h' , width = 120 , minwidth = 120 , stretch = 'no' ,anchor = 'e' )
2300
2316
results_tree .column ('ctime_h' , width = 160 , minwidth = 120 , stretch = 'no' ,anchor = 'e' )
2301
2317
2318
+ results_tree .bind ('<ButtonPress-1>' , self .tree_on_mouse_button_press_search_results )
2302
2319
results_tree .bind ('<Double-Button-1>' , self .double_left_button_results_tree )
2303
2320
results_tree .bind ('<Return>' , lambda event : self .return_results_tree ())
2304
2321
2322
+ self .REAL_SORT_COLUMN_INDEX_RESULTS = {}
2323
+
2324
+ for disply_column in self .real_display_columns :
2325
+ self .REAL_SORT_COLUMN_INDEX_RESULTS [disply_column ] = self .results_tree ["columns" ].index (self .REAL_SORT_COLUMN [disply_column ])
2326
+
2305
2327
results_tree_yview = results_tree .yview
2306
2328
self .results_tree_scrollbar = Scrollbar (treeframe , orient = 'vertical' , command = results_tree_yview ,takefocus = False )
2307
2329
@@ -3072,19 +3094,22 @@ def find_show_results_core(self):
3072
3094
3073
3095
if not children :
3074
3096
#self.results_tree.delete(*children)
3075
- self .found_item_to_data = {}
3097
+ self_found_item_to_data = self .found_item_to_data = {}
3076
3098
3099
+ self_results_tree_insert = self .results_tree .insert
3100
+ sep_join = sep .join
3077
3101
for record in librer_core .records :
3078
3102
if record .find_results :
3079
3103
record_name = librer_core .get_record_name (record )
3080
- record_node = self .results_tree .insert ('' ,'end' ,text = record_name ,values = (len (record .find_results ),'' ))
3104
+ record_node = self_results_tree_insert ('' ,'end' ,text = record_name ,values = (record_name ,0 ,'' ,0 ,'' ))
3105
+ #len(record.find_results),''
3081
3106
3082
3107
if self .cfg .get (CFG_KEY_expand_search_results ):
3083
3108
self .results_tree .item (record_node ,open = True )
3084
3109
3085
- for res_item ,res_size ,res_mtime in record .find_results :
3086
- 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 ))))
3087
- self . found_item_to_data [item ]= (record ,res_item )
3110
+ for res_item ,res_size ,res_mtime in sorted ( record .find_results , key = lambda x : x ) :
3111
+ item = self_results_tree_insert (record_node ,'end' ,text = sep_join (res_item ),values = (sep_join ( res_item ), res_size , bytes_to_str (res_size ), res_mtime ,strftime ('%Y/%m/%d %H:%M:%S' ,localtime_catched (res_mtime ))))
3112
+ self_found_item_to_data [item ]= (record ,res_item )
3088
3113
3089
3114
children = self .results_tree .get_children ()
3090
3115
@@ -3942,6 +3967,25 @@ def select_and_focus(self,item):
3942
3967
3943
3968
self .tree .update ()
3944
3969
3970
+ def tree_on_mouse_button_press_search_results (self ,event ):
3971
+ tree = event .widget
3972
+ region = tree .identify ("region" , event .x , event .y )
3973
+
3974
+ if region != 'separator' :
3975
+ if region == 'heading' :
3976
+ col_nr = tree .identify_column (event .x )
3977
+ colname = col_nr if col_nr == '#0' else tree .column (col_nr ,'id' )
3978
+
3979
+ #print('colname:',colname)
3980
+ ##0,size_h,ctime_h
3981
+
3982
+ #if colname in self.REAL_SORT_COLUMN:
3983
+ self .column_sort_click_results (tree ,colname )
3984
+
3985
+ # self.column_sort_click(tree,colname)
3986
+ elif item := tree .identify ('item' ,event .x ,event .y ):
3987
+ pass
3988
+
3945
3989
def tree_on_mouse_button_press (self ,event ):
3946
3990
if not self .block_processing_stack :
3947
3991
self .menubar_unpost ()
@@ -4229,14 +4273,17 @@ def tree_sort_item(self,parent_item):
4229
4273
#if len(children)>1:
4230
4274
4231
4275
self_GROUP = self .GROUP
4276
+ tree_item = tree .item
4277
+
4278
+ self_REAL_SORT_COLUMN_INDEX_colname = self .REAL_SORT_COLUMN_INDEX [colname ]
4232
4279
4233
4280
for item in children :
4234
- values = tree . item (item ,'values' )
4281
+ values = tree_item (item ,'values' )
4235
4282
4236
4283
if not values : #dummy node
4237
4284
continue
4238
4285
4239
- sortval_org = values [self . REAL_SORT_COLUMN_INDEX [ colname ] ]
4286
+ sortval_org = values [self_REAL_SORT_COLUMN_INDEX_colname ]
4240
4287
4241
4288
sortval = (int (sortval_org ) if sortval_org .isdigit () else 0 ) if is_numeric else sortval_org
4242
4289
@@ -4270,6 +4317,79 @@ def column_sort_set_arrow(self, tree):
4270
4317
colname ,sort_index ,is_numeric ,reverse ,group_code ,dir_code ,non_dir_code = self .column_sort_last_params
4271
4318
tree .heading (colname , text = self .org_label [colname ] + ' ' + str ('\u25BC ' if reverse else '\u25B2 ' ) )
4272
4319
4320
+ #@logwrapper
4321
+ def column_sort_click_results (self , tree , colname ):
4322
+ prev_colname ,prev_sort_index ,prev_is_numeric ,prev_reverse ,prev_group_code ,prev_dir_code ,prev_non_dir_code = self .column_sort_last_params_results
4323
+ reverse = not prev_reverse if colname == prev_colname else prev_reverse
4324
+ tree .heading (prev_colname , text = self .org_label [prev_colname ])
4325
+
4326
+ group_code ,dir_code ,non_dir_code = (2 ,1 ,0 ) if reverse else (0 ,1 ,2 )
4327
+
4328
+ sort_index = self .REAL_SORT_COLUMN_INDEX [colname ]
4329
+ is_numeric = self .REAL_SORT_COLUMN_IS_NUMERIC [colname ]
4330
+ self .column_sort_last_params_results = (colname ,sort_index ,is_numeric ,reverse ,group_code ,dir_code ,non_dir_code )
4331
+ self .cfg .set (CFG_SORTING_RESULTS ,self .column_sort_last_params_results )
4332
+
4333
+ colname_real = self .REAL_SORT_COLUMN [colname ]
4334
+
4335
+ self .column_sort_results (tree )
4336
+
4337
+ def tree_sort_item_results (self ,parent_item ):
4338
+ tree = self .results_tree
4339
+
4340
+ colname ,sort_index ,is_numeric ,reverse ,group_code ,dir_code ,non_dir_code = self .column_sort_last_params_results
4341
+
4342
+ real_column_to_sort = self .REAL_SORT_COLUMN [colname ]
4343
+
4344
+ tlist = []
4345
+ tree_set = tree .set
4346
+ tlist_append = tlist .append
4347
+
4348
+ dir_or_dirlink = (self .DIR ,self .DIRLINK )
4349
+
4350
+ children = tree .get_children (parent_item )
4351
+
4352
+ self_REAL_SORT_COLUMN_INDEX_RESULTS_colname = self .REAL_SORT_COLUMN_INDEX_RESULTS [colname ]
4353
+
4354
+ tree_item = tree .item
4355
+
4356
+ for item in children :
4357
+ values = tree_item (item ,'values' )
4358
+
4359
+ sortval_org = values [self_REAL_SORT_COLUMN_INDEX_RESULTS_colname ]
4360
+
4361
+ sortval = (int (sortval_org ) if sortval_org .isdigit () else 0 ) if is_numeric else sortval_org
4362
+
4363
+ tlist_append ( ( sortval ,item ) )
4364
+
4365
+ tlist .sort (reverse = reverse ,key = lambda x : x [0 ])
4366
+
4367
+ #if not parent_item:
4368
+ # parent_item=''
4369
+
4370
+ tree_move = tree .move
4371
+ _ = {tree_move (item_temp , parent_item , index ) for index ,(val_tuple ,item_temp ) in enumerate (sorted (tlist ,reverse = reverse ,key = lambda x : x [0 ]) ) }
4372
+
4373
+ #@restore_status_line
4374
+ #@block_and_log
4375
+ def column_sort_results (self , tree ):
4376
+ #self.status('Sorting...')
4377
+ colname ,sort_index ,is_numeric ,reverse ,group_code ,dir_code ,non_dir_code = self .column_sort_last_params_results
4378
+
4379
+ self .column_sort_set_arrow_results (tree )
4380
+
4381
+ children = self .results_tree .get_children ('' )
4382
+
4383
+ for item in children :
4384
+ self .tree_sort_item_results (item )
4385
+
4386
+ tree .update ()
4387
+ #self.visible_items_uptodate=False
4388
+
4389
+ def column_sort_set_arrow_results (self , tree ):
4390
+ colname ,sort_index ,is_numeric ,reverse ,group_code ,dir_code ,non_dir_code = self .column_sort_last_params_results
4391
+ tree .heading (colname , text = self .org_label [colname ] + ' ' + str ('\u25BC ' if reverse else '\u25B2 ' ) )
4392
+
4273
4393
def path_to_scan_set (self ,path ):
4274
4394
print ('path_to_scan_set' ,path )
4275
4395
0 commit comments