mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Minor enhancements and consistency fixes for CreateDatabase + CreateTable dialogs:
- Fetch charsets from collations dataset rather than firing an extra "SHOW CHARSET" - Move fetching defaultCharset to existing TRY clause. No functionality change, just more consistent. - Sort all comboboxes with charsets and collations alphabetically - Leave the responsibility for disabling the comboboxes on old servers to the code rather than to the DFM file. - Adapt Enabled-property of TLables to the comboboxes they belong to.
This commit is contained in:
@@ -69,7 +69,6 @@ object CreateDatabaseForm: TCreateDatabaseForm
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Enabled = False
|
||||
ItemHeight = 13
|
||||
Sorted = True
|
||||
TabOrder = 1
|
||||
@@ -104,7 +103,6 @@ object CreateDatabaseForm: TCreateDatabaseForm
|
||||
Width = 221
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
Enabled = False
|
||||
ItemHeight = 13
|
||||
Sorted = True
|
||||
TabOrder = 2
|
||||
|
||||
@@ -28,7 +28,6 @@ type
|
||||
function GetCreateStatement: String;
|
||||
private
|
||||
{ Private declarations }
|
||||
listCharsets : TStringList;
|
||||
dsCollations : TDataSet;
|
||||
defaultCharset : String;
|
||||
currentCollation : String;
|
||||
@@ -49,24 +48,37 @@ uses main, childwin, helpers;
|
||||
Fetch list with character sets and collations from the server
|
||||
}
|
||||
procedure TCreateDatabaseForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
charset: String;
|
||||
begin
|
||||
try
|
||||
listCharsets := Mainform.Childwin.GetCol('SHOW CHARACTER SET');
|
||||
dsCollations := Mainform.Childwin.ExecSelectQuery('SHOW COLLATION');
|
||||
// Detect servers default charset
|
||||
defaultCharset := Mainform.Childwin.GetVar( 'SHOW VARIABLES LIKE '+esc('character_set_server'), 1 );
|
||||
except
|
||||
// Ignore it when the above statements don't work on pre 4.1 servers.
|
||||
// If the list(s) are nil, disable the combobox(es), so we create the db without charset.
|
||||
end;
|
||||
|
||||
if (listCharsets <> nil) and (listCharsets.Count > 0) then
|
||||
// Create a list with charsets from collations dataset
|
||||
comboCharset.Enabled := dsCollations <> nil;
|
||||
lblCharset.Enabled := comboCharset.Enabled;
|
||||
if comboCharset.Enabled then
|
||||
begin
|
||||
comboCharset.Enabled := True;
|
||||
comboCharset.Items := listCharsets;
|
||||
// Detect servers default charset
|
||||
defaultCharset := Mainform.Childwin.GetVar( 'SHOW VARIABLES LIKE '+esc('character_set_server'), 1 );
|
||||
comboCharset.Items.BeginUpdate;
|
||||
dsCollations.First;
|
||||
while not dsCollations.Eof do
|
||||
begin
|
||||
charset := dsCollations.FieldByName('Charset').AsString;
|
||||
if comboCharset.Items.IndexOf(charset) = -1 then
|
||||
comboCharset.Items.Add(charset);
|
||||
dsCollations.Next;
|
||||
end;
|
||||
comboCharset.Items.EndUpdate;
|
||||
end;
|
||||
|
||||
comboCollation.Enabled := dsCollations <> nil;
|
||||
lblCollation.Enabled := comboCollation.Enabled;
|
||||
|
||||
// Setup SynMemoPreview
|
||||
SynMemoPreview.Highlighter := Mainform.Childwin.SynSQLSyn1;
|
||||
|
||||
@@ -75,7 +75,7 @@ object CreateTableForm: TCreateTableForm
|
||||
Height = 9
|
||||
Shape = bsTopLine
|
||||
end
|
||||
object lblCharacterset: TLabel
|
||||
object lblCharset: TLabel
|
||||
Left = 264
|
||||
Top = 41
|
||||
Width = 66
|
||||
@@ -426,8 +426,8 @@ object CreateTableForm: TCreateTableForm
|
||||
Width = 153
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
Enabled = False
|
||||
ItemHeight = 13
|
||||
Sorted = True
|
||||
TabOrder = 14
|
||||
OnChange = comboCharsetChange
|
||||
end
|
||||
@@ -437,8 +437,8 @@ object CreateTableForm: TCreateTableForm
|
||||
Width = 153
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
Enabled = False
|
||||
ItemHeight = 13
|
||||
Sorted = True
|
||||
TabOrder = 15
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,7 +50,7 @@ type
|
||||
Label5: TLabel;
|
||||
Bevel2: TBevel;
|
||||
ListboxColumns: TListBox;
|
||||
lblCharacterset: TLabel;
|
||||
lblCharset: TLabel;
|
||||
lblCollation: TLabel;
|
||||
comboCharset: TComboBox;
|
||||
comboCollation: TComboBox;
|
||||
@@ -86,7 +86,6 @@ type
|
||||
procedure comboCharsetChange(Sender: TObject);
|
||||
private
|
||||
index : Integer;
|
||||
listCharsets : TStringList;
|
||||
dsCollations : TDataSet;
|
||||
defaultCharset : String;
|
||||
{ Private declarations }
|
||||
@@ -130,24 +129,37 @@ end;
|
||||
@todo: share these lists with other forms, fx createdatabase
|
||||
}
|
||||
procedure TCreateTableForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
charset : String;
|
||||
begin
|
||||
try
|
||||
listCharsets := Mainform.Childwin.GetCol('SHOW CHARACTER SET');
|
||||
dsCollations := Mainform.Childwin.ExecSelectQuery('SHOW COLLATION');
|
||||
// Detect servers default charset
|
||||
defaultCharset := Mainform.Childwin.GetVar( 'SHOW VARIABLES LIKE '+esc('character_set_server'), 1 );
|
||||
except
|
||||
// Ignore it when the above statements don't work on pre 4.1 servers.
|
||||
// If the list(s) are nil, disable the combobox(es), so we create the db without charset.
|
||||
end;
|
||||
|
||||
if (listCharsets <> nil) and (listCharsets.Count > 0) then
|
||||
// Create a list with charsets from collations dataset
|
||||
comboCharset.Enabled := dsCollations <> nil;
|
||||
lblCharset.Enabled := comboCharset.Enabled;
|
||||
if comboCharset.Enabled then
|
||||
begin
|
||||
comboCharset.Enabled := True;
|
||||
comboCharset.Items := listCharsets;
|
||||
// Detect servers default charset
|
||||
defaultCharset := Mainform.Childwin.GetVar( 'SHOW VARIABLES LIKE '+esc('character_set_server'), 1 );
|
||||
comboCharset.Items.BeginUpdate;
|
||||
dsCollations.First;
|
||||
while not dsCollations.Eof do
|
||||
begin
|
||||
charset := dsCollations.FieldByName('Charset').AsString;
|
||||
if comboCharset.Items.IndexOf(charset) = -1 then
|
||||
comboCharset.Items.Add(charset);
|
||||
dsCollations.Next;
|
||||
end;
|
||||
comboCharset.Items.EndUpdate;
|
||||
end;
|
||||
|
||||
comboCollation.Enabled := dsCollations <> nil;
|
||||
lblCollation.Enabled := comboCollation.Enabled;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user