mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Fix stuff on "Import Textfile" dialog:
* Store settings in FormDestroy instead of btnImportClick * Restore settings in FormCreate instead of FormShow * Turn editFilename into a TButtonedEdit, including the file browse button * Turn SpeedButtons for column moving into a TToolbar, to remove hackish code for assigning icons * Increase dropdown items on charset pulldown, to decrease the need to scroll.
This commit is contained in:
@@ -15,6 +15,7 @@ object loaddataform: Tloaddataform
|
||||
OldCreateOrder = False
|
||||
Position = poMainFormCenter
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
OnShow = FormShow
|
||||
DesignSize = (
|
||||
423
|
||||
@@ -70,15 +71,6 @@ object loaddataform: Tloaddataform
|
||||
DesignSize = (
|
||||
403
|
||||
90)
|
||||
object btnOpenFile: TSpeedButton
|
||||
Left = 362
|
||||
Top = 24
|
||||
Width = 22
|
||||
Height = 22
|
||||
Anchors = [akTop, akRight]
|
||||
Flat = True
|
||||
OnClick = btnOpenFileClick
|
||||
end
|
||||
object lblFilename: TLabel
|
||||
Left = 10
|
||||
Top = 27
|
||||
@@ -95,23 +87,29 @@ object loaddataform: Tloaddataform
|
||||
Caption = '&Character set:'
|
||||
FocusControl = comboCharset
|
||||
end
|
||||
object editFilename: TEdit
|
||||
object editFilename: TButtonedEdit
|
||||
Left = 104
|
||||
Top = 24
|
||||
Width = 252
|
||||
Width = 289
|
||||
Height = 21
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
Images = MainForm.ImageListMain
|
||||
RightButton.ImageIndex = 51
|
||||
RightButton.Visible = True
|
||||
TabOrder = 0
|
||||
Text = 'editFilename'
|
||||
OnChange = editFilenameChange
|
||||
OnDblClick = btnOpenFileClick
|
||||
OnRightButtonClick = btnOpenFileClick
|
||||
end
|
||||
object comboCharset: TComboBox
|
||||
Left = 104
|
||||
Top = 51
|
||||
Width = 252
|
||||
Width = 289
|
||||
Height = 21
|
||||
Style = csDropDownList
|
||||
Anchors = [akLeft, akTop, akRight]
|
||||
DropDownCount = 16
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
@@ -263,24 +261,6 @@ object loaddataform: Tloaddataform
|
||||
Height = 13
|
||||
Caption = 'Use Columns:'
|
||||
end
|
||||
object btnColUp: TSpeedButton
|
||||
Left = 150
|
||||
Top = 117
|
||||
Width = 25
|
||||
Height = 25
|
||||
Anchors = [akTop, akRight]
|
||||
Flat = True
|
||||
OnClick = btnColUpClick
|
||||
end
|
||||
object btnColDown: TSpeedButton
|
||||
Left = 150
|
||||
Top = 142
|
||||
Width = 25
|
||||
Height = 25
|
||||
Anchors = [akTop, akRight]
|
||||
Flat = True
|
||||
OnClick = btnColDownClick
|
||||
end
|
||||
object comboDatabase: TComboBox
|
||||
Left = 10
|
||||
Top = 26
|
||||
@@ -352,6 +332,32 @@ object loaddataform: Tloaddataform
|
||||
OnClick = chkIgnoreClick
|
||||
end
|
||||
end
|
||||
object ToolBarColMove: TToolBar
|
||||
Left = 149
|
||||
Top = 117
|
||||
Width = 23
|
||||
Height = 44
|
||||
Align = alNone
|
||||
AutoSize = True
|
||||
Caption = 'ToolBarColMove'
|
||||
Images = MainForm.ImageListMain
|
||||
TabOrder = 4
|
||||
object btnColUp: TToolButton
|
||||
Left = 0
|
||||
Top = 0
|
||||
Caption = 'btnColUp'
|
||||
ImageIndex = 74
|
||||
Wrap = True
|
||||
OnClick = btnColUpClick
|
||||
end
|
||||
object btnColDown: TToolButton
|
||||
Left = 0
|
||||
Top = 22
|
||||
Caption = 'btnColDown'
|
||||
ImageIndex = 75
|
||||
OnClick = btnColDownClick
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
object OpenDialogCSVFile: TOpenDialog
|
||||
|
||||
@@ -10,7 +10,7 @@ interface
|
||||
|
||||
uses
|
||||
Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ComCtrls, CheckLst,
|
||||
SynRegExpr, Buttons,
|
||||
SynRegExpr, Buttons, ExtCtrls, ToolWin,
|
||||
mysql_connection;
|
||||
|
||||
type
|
||||
@@ -27,16 +27,16 @@ type
|
||||
comboTable: TComboBox;
|
||||
lblColumns: TLabel;
|
||||
chklistColumns: TCheckListBox;
|
||||
btnColUp: TSpeedButton;
|
||||
btnColDown: TSpeedButton;
|
||||
ToolBarColMove: TToolBar;
|
||||
btnColUp: TToolButton;
|
||||
btnColDown: TToolButton;
|
||||
grpOptions: TGroupBox;
|
||||
chkLowPriority: TCheckBox;
|
||||
chkReplace: TCheckBox;
|
||||
chkIgnore: TCheckBox;
|
||||
lblDuplicates: TLabel;
|
||||
grpFilename: TGroupBox;
|
||||
editFilename: TEdit;
|
||||
btnOpenFile: TSpeedButton;
|
||||
editFilename: TButtonedEdit;
|
||||
grpFields: TGroupBox;
|
||||
lblFieldTerminater: TLabel;
|
||||
lblFieldEncloser: TLabel;
|
||||
@@ -56,6 +56,7 @@ type
|
||||
comboCharset: TComboBox;
|
||||
lblCharset: TLabel;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
procedure editFilenameChange(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
procedure comboDatabaseChange(Sender: TObject);
|
||||
@@ -81,18 +82,40 @@ uses Main, helpers;
|
||||
|
||||
|
||||
|
||||
{**
|
||||
FormCreat
|
||||
}
|
||||
procedure Tloaddataform.FormCreate(Sender: TObject);
|
||||
begin
|
||||
// Assign images from main imagelist to speedbuttons
|
||||
Mainform.ImageListMain.GetBitmap(52, btnOpenFile.Glyph);
|
||||
Mainform.ImageListMain.GetBitmap(74, btnColUp.Glyph);
|
||||
Mainform.ImageListMain.GetBitmap(75, btnColDown.Glyph);
|
||||
InheritFont(Font);
|
||||
// Restore settings
|
||||
editFilename.Text := GetRegValue(REGNAME_CSV_FILENAME, '');
|
||||
editFieldTerminator.Text := GetRegValue(REGNAME_CSV_SEPARATOR, DEFAULT_CSV_SEPARATOR);
|
||||
editFieldEncloser.Text := GetRegValue(REGNAME_CSV_ENCLOSER, DEFAULT_CSV_ENCLOSER);
|
||||
editLineTerminator.Text := GetRegValue(REGNAME_CSV_TERMINATOR, DEFAULT_CSV_TERMINATOR);
|
||||
chkFieldsEnclosedOptionally.Checked := GetRegValue(REGNAME_CSV_ENCLOPTION, chkFieldsEnclosedOptionally.Checked);
|
||||
editFieldEscaper.Text := GetRegValue(REGNAME_CSV_ESCAPER, editFieldEscaper.Text);
|
||||
updownIgnoreLines.Position := GetRegValue(REGNAME_CSV_IGNORELINES, updownIgnoreLines.Position);
|
||||
chkLowPriority.Checked := GetRegValue(REGNAME_CSV_LOWPRIO, chkLowPriority.Checked);
|
||||
chkReplace.Checked := GetRegValue(REGNAME_CSV_REPLACE, chkReplace.Checked);
|
||||
chkIgnore.Checked := GetRegValue(REGNAME_CSV_IGNORE, chkIgnore.Checked);
|
||||
end;
|
||||
|
||||
|
||||
procedure Tloaddataform.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
// Save settings
|
||||
OpenRegistry;
|
||||
MainReg.WriteString(REGNAME_CSV_FILENAME, editFilename.Text);
|
||||
MainReg.WriteString(REGNAME_CSV_SEPARATOR, editFieldTerminator.Text);
|
||||
MainReg.WriteString(REGNAME_CSV_ENCLOSER, editFieldEncloser.Text);
|
||||
MainReg.WriteString(REGNAME_CSV_TERMINATOR, editLineTerminator.Text);
|
||||
MainReg.WriteBool(REGNAME_CSV_ENCLOPTION, chkFieldsEnclosedOptionally.Checked);
|
||||
MainReg.WriteString(REGNAME_CSV_ESCAPER, editFieldEscaper.Text);
|
||||
MainReg.WriteInteger(REGNAME_CSV_IGNORELINES, updownIgnoreLines.Position);
|
||||
MainReg.WriteBool(REGNAME_CSV_LOWPRIO, chkLowPriority.Checked);
|
||||
MainReg.WriteBool(REGNAME_CSV_REPLACE, chkReplace.Checked);
|
||||
MainReg.WriteBool(REGNAME_CSV_IGNORE, chkIgnore.Checked);
|
||||
end;
|
||||
|
||||
|
||||
procedure Tloaddataform.FormShow(Sender: TObject);
|
||||
begin
|
||||
// read dbs and Tables from treeview
|
||||
@@ -101,21 +124,7 @@ begin
|
||||
comboDatabase.ItemIndex := comboDatabase.Items.IndexOf( Mainform.ActiveDatabase );
|
||||
if comboDatabase.ItemIndex = -1 then
|
||||
comboDatabase.ItemIndex := 0;
|
||||
|
||||
comboDatabaseChange(self);
|
||||
// filename
|
||||
editFilename.Text := GetRegValue(REGNAME_CSV_FILENAME, '');
|
||||
// Use options from CSV export
|
||||
editFieldTerminator.Text := GetRegValue(REGNAME_CSV_SEPARATOR, DEFAULT_CSV_SEPARATOR);
|
||||
editFieldEncloser.Text := GetRegValue(REGNAME_CSV_ENCLOSER, DEFAULT_CSV_ENCLOSER);
|
||||
editLineTerminator.Text := GetRegValue(REGNAME_CSV_TERMINATOR, DEFAULT_CSV_TERMINATOR);
|
||||
// Other options
|
||||
chkFieldsEnclosedOptionally.Checked := GetRegValue(REGNAME_CSV_ENCLOPTION, chkFieldsEnclosedOptionally.Checked);
|
||||
editFieldEscaper.Text := GetRegValue(REGNAME_CSV_ESCAPER, editFieldEscaper.Text);
|
||||
updownIgnoreLines.Position := GetRegValue(REGNAME_CSV_IGNORELINES, updownIgnoreLines.Position);
|
||||
chkLowPriority.Checked := GetRegValue(REGNAME_CSV_LOWPRIO, chkLowPriority.Checked);
|
||||
chkReplace.Checked := GetRegValue(REGNAME_CSV_REPLACE, chkReplace.Checked);
|
||||
chkIgnore.Checked := GetRegValue(REGNAME_CSV_IGNORE, chkIgnore.Checked);
|
||||
end;
|
||||
|
||||
|
||||
@@ -210,22 +219,6 @@ var
|
||||
end;
|
||||
begin
|
||||
|
||||
// Save settings
|
||||
OpenRegistry;
|
||||
// filename
|
||||
MainReg.WriteString( REGNAME_CSV_FILENAME, editFilename.Text );
|
||||
// Use options from CSV export
|
||||
MainReg.WriteString( REGNAME_CSV_SEPARATOR, editFieldTerminator.Text );
|
||||
MainReg.WriteString( REGNAME_CSV_ENCLOSER, editFieldEncloser.Text );
|
||||
MainReg.WriteString( REGNAME_CSV_TERMINATOR, editLineTerminator.Text );
|
||||
// Other options
|
||||
MainReg.WriteBool( REGNAME_CSV_ENCLOPTION, chkFieldsEnclosedOptionally.Checked );
|
||||
MainReg.WriteString( REGNAME_CSV_ESCAPER, editFieldEscaper.Text );
|
||||
MainReg.WriteInteger( REGNAME_CSV_IGNORELINES, updownIgnoreLines.Position );
|
||||
MainReg.WriteBool( REGNAME_CSV_LOWPRIO, chkLowPriority.Checked );
|
||||
MainReg.WriteBool( REGNAME_CSV_REPLACE, chkReplace.Checked );
|
||||
MainReg.WriteBool( REGNAME_CSV_IGNORE, chkIgnore.Checked );
|
||||
|
||||
query := 'LOAD DATA ';
|
||||
|
||||
if chkLowPriority.Checked then
|
||||
|
||||
Reference in New Issue
Block a user