mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00

Additionally/Side effects: - TVTreeData structure moved to helpers.pas to be able to use it in new function GetSelectedNodesFromVT. - ListTablesEditing dropped. We don't need to disable any shortcut there because there is none set. - Avoid potential AVs when accessing not created items in TVTreeData.Captions
94 lines
2.4 KiB
ObjectPascal
94 lines
2.4 KiB
ObjectPascal
unit tblcomment;
|
|
|
|
|
|
// -------------------------------------
|
|
// Edit table-comment
|
|
// -------------------------------------
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
StdCtrls, ExtCtrls;
|
|
|
|
type
|
|
Ttablecomment = class(TForm)
|
|
Label1: TLabel;
|
|
EditComment: TEdit;
|
|
ButtonOK: TButton;
|
|
ButtonCancel: TButton;
|
|
Bevel1: TBevel;
|
|
ComboBoxTableName: TComboBox;
|
|
procedure ButtonCancelClick(Sender: TObject);
|
|
procedure ButtonOKClick(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure ComboBoxTableNameChange(Sender: TObject);
|
|
private
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
function tablecommentWindow(AOwner: TComponent): Boolean;
|
|
|
|
implementation
|
|
|
|
uses Childwin, helpers, Main;
|
|
|
|
{$R *.DFM}
|
|
|
|
{**
|
|
Create form on demand
|
|
@param TComponent Owner of form (should be calling form)
|
|
@return Boolean Form closed using modalresult mrOK
|
|
}
|
|
function tablecommentWindow(AOwner: TComponent): Boolean;
|
|
var
|
|
f : Ttablecomment;
|
|
begin
|
|
f := Ttablecomment.Create(AOwner);
|
|
Result := (f.ShowModal=mrOK);
|
|
FreeAndNil(f);
|
|
end;
|
|
|
|
|
|
procedure Ttablecomment.ButtonCancelClick(Sender: TObject);
|
|
begin
|
|
close;
|
|
end;
|
|
|
|
procedure Ttablecomment.ButtonOKClick(Sender: TObject);
|
|
begin
|
|
screen.Cursor := crHourGlass;
|
|
Mainform.Childwin.ExecUpdateQuery('ALTER TABLE ' + mainform.mask(ComboBoxTableName.Text) + ' COMMENT = ' + esc(EditComment.Text));
|
|
Mainform.Childwin.ShowDBProperties(self);
|
|
close;
|
|
end;
|
|
|
|
procedure Ttablecomment.FormShow(Sender: TObject);
|
|
var
|
|
i : integer;
|
|
NodeData : PVTreeData;
|
|
begin
|
|
// read tables
|
|
// messagedlg('sdf',mtwarning, [], 0);
|
|
ComboBoxTableName.Items.Clear;
|
|
for i:=0 to Length(Mainform.Childwin.VTRowDataListTables)-1 do
|
|
ComboBoxTableName.Items.Add( Mainform.Childwin.VTRowDataListTables[i].Captions[0] );
|
|
// Select the correct item in the tables dropdown
|
|
NodeData := Mainform.Childwin.ListTables.GetNodeData(Mainform.Childwin.ListTables.FocusedNode);
|
|
ComboBoxTableName.ItemIndex := ComboBoxTableName.Items.IndexOf(NodeData.Captions[0]);
|
|
ComboBoxTableNameChange( self );
|
|
end;
|
|
|
|
procedure Ttablecomment.ComboBoxTableNameChange(Sender: TObject);
|
|
begin
|
|
EditComment.Text := Mainform.Childwin.GetNamedVar(
|
|
'SHOW TABLE STATUS LIKE ''' + ComboBoxTableName.Text + '''',
|
|
'Comment'
|
|
);
|
|
end;
|
|
|
|
end.
|