mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 03:01:07 +08:00
Internal refactoring: Directly bind TDBObject's to nodes in ListTables, instead of copying everything to an internal array structure first. Most events on ListTables have their own procedures now. Also, when selecting a database in the tree without expanding it and a query tab is selected, do not fetch objects. Could annoy some SQL writers which won't see the objects in selected db highlighted in that case. On the other hand this avoids loading objects in situations where you don't need them. For larger databases this should be really helpful, e.g. for the reporter of issue #1742.
This commit is contained in:
@ -16,6 +16,7 @@ type
|
||||
Rows, Size, Version, AvgRowLen, MaxDataLen, IndexLen, DataLen, DataFree, AutoInc, CheckSum: Int64;
|
||||
NodeType: TListNodeType;
|
||||
end;
|
||||
PDBObject = ^TDBObject;
|
||||
TDBObjectList = TObjectList<TDBObject>;
|
||||
|
||||
{$M+} // Needed to add published properties
|
||||
@ -96,6 +97,7 @@ type
|
||||
FCharsetTable: TMySQLQuery;
|
||||
FInformationSchemaObjects: TStringList;
|
||||
FDBObjectLists: TStringList;
|
||||
FObjectNamesInSelectedDB: TStrings;
|
||||
procedure SetActive(Value: Boolean);
|
||||
procedure SetDatabase(Value: String);
|
||||
function GetThreadId: Cardinal;
|
||||
@ -115,6 +117,7 @@ type
|
||||
function ParseDateTime(Str: String): TDateTime;
|
||||
procedure Log(Category: TMySQLLogCategory; Msg: String);
|
||||
procedure ClearCache;
|
||||
procedure SetObjectNamesInSelectedDB;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -153,6 +156,7 @@ type
|
||||
property CharsetTable: TMySQLQuery read GetCharsetTable;
|
||||
property CharsetList: TStringList read GetCharsetList;
|
||||
property InformationSchemaObjects: TStringList read GetInformationSchemaObjects;
|
||||
property ObjectNamesInSelectedDB: TStrings read FObjectNamesInSelectedDB write FObjectNamesInSelectedDB;
|
||||
published
|
||||
property Active: Boolean read FActive write SetActive default False;
|
||||
property Database: String read FDatabase write SetDatabase;
|
||||
@ -452,6 +456,7 @@ begin
|
||||
FOnDatabaseChanged(Value);
|
||||
end else
|
||||
Query('USE '+QuoteIdent(Value), False);
|
||||
SetObjectNamesInSelectedDB;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -1122,6 +1127,26 @@ begin
|
||||
if not Assigned(FDBObjectLists) then
|
||||
FDBObjectLists := TStringList.Create;
|
||||
FDBObjectLists.AddObject(db, Result);
|
||||
|
||||
SetObjectNamesInSelectedDB;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
procedure TMySQLConnection.SetObjectNamesInSelectedDB;
|
||||
var
|
||||
i: Integer;
|
||||
Objects: TDBObjectList;
|
||||
ObjNames: String;
|
||||
begin
|
||||
// Add object names to additional stringlist
|
||||
if Assigned(FObjectNamesInSelectedDB) and DbObjectsCached(FDatabase) then begin
|
||||
Objects := GetDbObjects(FDatabase);
|
||||
for i:=0 to Objects.Count-1 do
|
||||
ObjNames := ObjNames + Objects[i].Name + CRLF;
|
||||
if FObjectNamesInSelectedDB.Text <> ObjNames then
|
||||
FObjectNamesInSelectedDB.Text := ObjNames;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user