瀏覽代碼

Bug 1446: Ordering of columns that are invisible by default is not preserved

https://winscp.net/tracker/1446

Source commit: 9cd61caeb1f192ae3eaed627eddbe3ea60f7b205
Martin Prikryl 9 年之前
父節點
當前提交
2a59a8f548
共有 1 個文件被更改,包括 14 次插入14 次删除
  1. 14 14
      source/packages/my/ListViewColProperties.pas

+ 14 - 14
source/packages/my/ListViewColProperties.pas

@@ -277,6 +277,7 @@ begin
     for Index := 0 to Count - 1 do
       GetProperties(Index).Order := -1;
 
+    // First order invisible columns (not True), then visible (not not True)
     Phase := True;
     Order := 0;
 
@@ -294,19 +295,19 @@ begin
           Inc(Order);
         end;
       end;
-    until Phase;
 
-    // this does not make sure hidden columns are first,
-    // but it gets fixed on the next run
-    for Index := 0 to Count - 1 do
-    begin
-      Properties := GetProperties(Index);
-      if Properties.Order < 0 then
+      // add missing columns from the same visibility class
+      for Index := 0 to Count - 1 do
       begin
-        Properties.Order := Order;
-        Inc(Order);
+        Properties := GetProperties(Index);
+        if (Properties.Visible = Phase) and
+           (Properties.Order < 0) then
+        begin
+          Properties.Order := Order;
+          Inc(Order);
+        end;
       end;
-    end;
+    until Phase;
 
     if ColumnsExists then
       UpdateListViewOrder;
@@ -325,12 +326,11 @@ begin
   S := CutToChar(Value, '|', True);
   WidthsStr := CutToChar(S, '@', True);
   PixelsPerInch := LoadPixelsPerInch(S);
+  SetWidthsStr(WidthsStr, PixelsPerInch);
+  // Have to set order after visibility, otherwise we lost ordering of columns that are invisible by default,
+  // but visible by configuration (as they would get ordered to the front)
   OrderStr := CutToChar(Value, '|', True);
-  // set first orders, only than the widths/visibility,
-  // as setting visibility can reorder hidden/visible columns
-  // as needed, while setting order cannot ensure this
   SetOrderStr(OrderStr);
-  SetWidthsStr(WidthsStr, PixelsPerInch);
 end;
 
 procedure TCustomListViewColProperties.SetVisible(Index: Integer; Value: Boolean);