Unify default sorting of database objects in tree and lists. Fixes issue #1799.

This commit is contained in:
Ansgar Becker
2010-03-25 21:03:37 +00:00
parent e47a7c6158
commit aa9525e527
2 changed files with 20 additions and 3 deletions

View File

@ -5672,7 +5672,7 @@ begin
end
else begin
// Compare Strings
Result := AnsiCompareText( CellText1, CellText2 );
Result := CompareText( CellText1, CellText2 );
end;
end;

View File

@ -3,7 +3,8 @@ unit mysql_connection;
interface
uses
Classes, SysUtils, windows, mysql_api, mysql_structures, SynRegExpr, Contnrs, Generics.Collections, DateUtils, Types;
Classes, SysUtils, windows, mysql_api, mysql_structures, SynRegExpr, Contnrs, Generics.Collections, Generics.Defaults,
DateUtils, Types;
type
{ TDBObjectList and friends }
@ -19,6 +20,10 @@ type
PDBObject = ^TDBObject;
TDBObjectList = TObjectList<TDBObject>;
TDBObjectComparer = class(TComparer<TDBObject>)
function Compare(const Left, Right: TDBObject): Integer; override;
end;
{$M+} // Needed to add published properties
{ TConnectionParameters }
@ -965,7 +970,7 @@ begin
if DbObjectsCached(db) then
Result := FDBObjectLists.Objects[FDBObjectLists.IndexOf(db)] as TDBObjectList
else begin
Result := TDBObjectList.Create;
Result := TDBObjectList.Create(TDBObjectComparer.Create);
Results := nil;
rx := TRegExpr.Create;
rx.ModifierI := True;
@ -1127,6 +1132,9 @@ begin
FreeAndNil(Results);
end;
// Sort list like it get sorted in MainForm.vstCompareNodes
Result.Sort;
// Add list of objects in this database to cached list of all databases
if not Assigned(FDBObjectLists) then
FDBObjectLists := TStringList.Create;
@ -1365,4 +1373,13 @@ end;
{ TDBObjectComparer }
function TDBObjectComparer.Compare(const Left, Right: TDBObject): Integer;
begin
// Simple sort method for a TDBObjectList
Result := CompareText(Left.Name, Right.Name);
end;
end.