mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Move helpers:GetIndexIcon to TTableKey.GetImageIndex
This commit is contained in:
@ -235,7 +235,7 @@ begin
|
||||
end;
|
||||
1: case Node.Parent.Index of
|
||||
nColumns: ImageIndex := ICONINDEX_FIELD;
|
||||
nKeys: ImageIndex := GetIndexIcon(FKeys[Node.Index].IndexType);
|
||||
nKeys: ImageIndex := FKeys[Node.Index].ImageIndex;
|
||||
nForeignKeys: ImageIndex := ICONINDEX_FOREIGNKEY;
|
||||
else raise Exception.Create(_(SUnhandledNodeIndex));
|
||||
end;
|
||||
|
@ -108,6 +108,7 @@ type
|
||||
TTableKey = class(TObject)
|
||||
private
|
||||
FConnection: TDBConnection;
|
||||
function GetImageIndex: Integer;
|
||||
public
|
||||
Name, OldName: String;
|
||||
IndexType, OldIndexType, Algorithm: String;
|
||||
@ -117,6 +118,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Modification(Sender: TObject);
|
||||
function SQLCode: String;
|
||||
property ImageIndex: Integer read GetImageIndex;
|
||||
end;
|
||||
TTableKeyList = TObjectList<TTableKey>;
|
||||
|
||||
@ -5254,6 +5256,17 @@ begin
|
||||
Modified := True;
|
||||
end;
|
||||
|
||||
function TTableKey.GetImageIndex: Integer;
|
||||
begin
|
||||
// Detect key icon index for specified index
|
||||
if IndexType = PKEY then Result := ICONINDEX_PRIMARYKEY
|
||||
else if IndexType = KEY then Result := ICONINDEX_INDEXKEY
|
||||
else if IndexType = UKEY then Result := ICONINDEX_UNIQUEKEY
|
||||
else if IndexType = FKEY then Result := ICONINDEX_FULLTEXTKEY
|
||||
else if IndexType = SKEY then Result := ICONINDEX_SPATIALKEY
|
||||
else Result := -1;
|
||||
end;
|
||||
|
||||
function TTableKey.SQLCode: String;
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -305,7 +305,6 @@ type
|
||||
function ParamStrToBlob(out cbData: DWORD): Pointer;
|
||||
function CheckForSecondInstance: Boolean;
|
||||
function GetParentFormOrFrame(Comp: TWinControl): TWinControl;
|
||||
function GetIndexIcon(IndexType: String): Integer;
|
||||
function KeyPressed(Code: Integer): Boolean;
|
||||
function GeneratePassword(Len: Integer): String;
|
||||
procedure InvalidateVT(VT: TVirtualStringTree; RefreshTag: Integer; ImmediateRepaint: Boolean);
|
||||
@ -2198,18 +2197,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function GetIndexIcon(IndexType: String): Integer;
|
||||
begin
|
||||
// Detect key icon index for specified index
|
||||
if IndexType = PKEY then Result := ICONINDEX_PRIMARYKEY
|
||||
else if IndexType = KEY then Result := ICONINDEX_INDEXKEY
|
||||
else if IndexType = UKEY then Result := ICONINDEX_UNIQUEKEY
|
||||
else if IndexType = FKEY then Result := ICONINDEX_FULLTEXTKEY
|
||||
else if IndexType = SKEY then Result := ICONINDEX_SPATIALKEY
|
||||
else Result := -1;
|
||||
end;
|
||||
|
||||
|
||||
function KeyPressed(Code: Integer): Boolean;
|
||||
var
|
||||
State: TKeyboardState;
|
||||
|
@ -4328,7 +4328,7 @@ var
|
||||
if col.ImageIndex = -1 then begin
|
||||
for k:=0 to SelectedTableKeys.Count-1 do begin
|
||||
if SelectedTableKeys[k].Columns.IndexOf(TblCol.Name) > -1 then begin
|
||||
col.ImageIndex := GetIndexIcon(SelectedTableKeys[k].IndexType);
|
||||
col.ImageIndex := SelectedTableKeys[k].ImageIndex;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
@ -914,7 +914,7 @@ begin
|
||||
X := 0;
|
||||
for i:=0 to FKeys.Count-1 do begin
|
||||
if FKeys[i].Columns.IndexOf(Col.Name) > -1 then begin
|
||||
ImageIndex := GetIndexIcon(FKeys[i].IndexType);
|
||||
ImageIndex := FKeys[i].ImageIndex;
|
||||
VT.Images.Draw(TargetCanvas, X, Y, ImageIndex);
|
||||
Inc(X, VT.Images.Width);
|
||||
end;
|
||||
@ -1482,7 +1482,7 @@ begin
|
||||
if Column <> 0 then Exit;
|
||||
if not (Kind in [ikNormal, ikSelected]) then Exit;
|
||||
case VT.GetNodeLevel(Node) of
|
||||
0: ImageIndex := GetIndexIcon(VT.Text[Node, 1]);
|
||||
0: ImageIndex := FKeys[Node.Index].ImageIndex;
|
||||
1: ImageIndex := 42;
|
||||
end;
|
||||
end;
|
||||
@ -1897,7 +1897,7 @@ begin
|
||||
IndexName := PKEY;
|
||||
end else
|
||||
IndexName := FKeys[i].Name + ' ('+FKeys[i].IndexType+')';
|
||||
Item := AddItem(menuAddToIndex, IndexName, GetIndexIcon(FKeys[i].IndexType));
|
||||
Item := AddItem(menuAddToIndex, IndexName, FKeys[i].ImageIndex);
|
||||
// Disable menuitem if all selected columns are already part of this index,
|
||||
// enable it if one or more selected columns are not.
|
||||
Item.Enabled := False;
|
||||
|
Reference in New Issue
Block a user