CSV import: add checkbox option for keeping dialog open after successful import, so the user may process multiple files with less clicks

This commit is contained in:
Ansgar Becker
2024-07-23 19:39:56 +02:00
parent 322b78b8b4
commit e521f7ab0c
4 changed files with 74 additions and 52 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: HeidiSQL\n" "Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n" "POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2024-06-29 09:34+0200\n" "PO-Revision-Date: 2024-07-23 19:36+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n" "Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n" "Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"Language: en\n" "Language: en\n"
@ -1099,6 +1099,9 @@ msgstr "Input file contains local formatted numbers, e.g. 1.234,56 in Germany"
msgid "Truncate destination table before import" msgid "Truncate destination table before import"
msgstr "Truncate destination table before import" msgstr "Truncate destination table before import"
msgid "Keep dialog open after import"
msgstr "Keep dialog open after import"
#. loaddataform..grpDuplicates..Caption #. loaddataform..grpDuplicates..Caption
#: loaddata.dfm:272 #: loaddata.dfm:272
msgid "Handling of duplicate rows" msgid "Handling of duplicate rows"

View File

@ -201,7 +201,7 @@ type
asCSVImportSeparator, asCSVImportEncloser, asCSVImportTerminator, asCSVImportFieldEscaper, asCSVImportWindowWidth, asCSVImportWindowHeight, asCSVImportSeparator, asCSVImportEncloser, asCSVImportTerminator, asCSVImportFieldEscaper, asCSVImportWindowWidth, asCSVImportWindowHeight,
asCSVImportFilename, asCSVImportFieldsEnclosedOptionally, asCSVImportIgnoreLines, asCSVImportLowPriority, asCSVImportLocalNumbers, asCSVImportFilename, asCSVImportFieldsEnclosedOptionally, asCSVImportIgnoreLines, asCSVImportLowPriority, asCSVImportLocalNumbers,
asCSVImportDuplicateHandling, asCSVImportParseMethod, asCSVImportDuplicateHandling, asCSVImportParseMethod, asCSVKeepDialogOpen,
asUpdatecheck, asUpdatecheckBuilds, asUpdatecheckInterval, asUpdatecheckLastrun, asUpdateCheckWindowWidth, asUpdateCheckWindowHeight, asUpdatecheck, asUpdatecheckBuilds, asUpdatecheckInterval, asUpdatecheckLastrun, asUpdateCheckWindowWidth, asUpdateCheckWindowHeight,
asTableToolsWindowWidth, asTableToolsWindowHeight, asTableToolsTreeWidth, asTableToolsWindowWidth, asTableToolsWindowHeight, asTableToolsTreeWidth,
asTableToolsFindTextTab, asTableToolsFindText, asTableToolsFindSQL, asTableToolsDatatype, asTableToolsFindCaseSensitive, asTableToolsFindMatchType, asFileImportWindowWidth, asFileImportWindowHeight, asTableToolsFindTextTab, asTableToolsFindText, asTableToolsFindSQL, asTableToolsDatatype, asTableToolsFindCaseSensitive, asTableToolsFindMatchType, asFileImportWindowWidth, asFileImportWindowHeight,
@ -3784,7 +3784,7 @@ begin
InitSetting(asCSVImportTerminator, 'CSVTerminator', 0, False, '\r\n'); InitSetting(asCSVImportTerminator, 'CSVTerminator', 0, False, '\r\n');
InitSetting(asCSVImportFieldEscaper, 'CSVImportFieldEscaperV2', 0, False, '"'); InitSetting(asCSVImportFieldEscaper, 'CSVImportFieldEscaperV2', 0, False, '"');
InitSetting(asCSVImportWindowWidth, 'CSVImportWindowWidth', 530); InitSetting(asCSVImportWindowWidth, 'CSVImportWindowWidth', 530);
InitSetting(asCSVImportWindowHeight, 'CSVImportWindowHeight', 530); InitSetting(asCSVImportWindowHeight, 'CSVImportWindowHeight', 550);
InitSetting(asCSVImportFilename, 'loadfilename', 0, False, ''); InitSetting(asCSVImportFilename, 'loadfilename', 0, False, '');
InitSetting(asCSVImportFieldsEnclosedOptionally, 'CSVImportFieldsEnclosedOptionallyV2', 0, True); InitSetting(asCSVImportFieldsEnclosedOptionally, 'CSVImportFieldsEnclosedOptionallyV2', 0, True);
InitSetting(asCSVImportIgnoreLines, 'CSVImportIgnoreLines', 1); InitSetting(asCSVImportIgnoreLines, 'CSVImportIgnoreLines', 1);
@ -3792,6 +3792,7 @@ begin
InitSetting(asCSVImportLocalNumbers, 'CSVImportLocalNumbers', 0, False); InitSetting(asCSVImportLocalNumbers, 'CSVImportLocalNumbers', 0, False);
InitSetting(asCSVImportDuplicateHandling, 'CSVImportDuplicateHandling', 2); InitSetting(asCSVImportDuplicateHandling, 'CSVImportDuplicateHandling', 2);
InitSetting(asCSVImportParseMethod, 'CSVImportParseMethod', 0); InitSetting(asCSVImportParseMethod, 'CSVImportParseMethod', 0);
InitSetting(asCSVKeepDialogOpen, 'CSVKeepDialogOpen', 0, False);
InitSetting(asUpdatecheck, 'Updatecheck', 0, False); InitSetting(asUpdatecheck, 'Updatecheck', 0, False);
InitSetting(asUpdatecheckBuilds, 'UpdatecheckBuilds', 0, False); InitSetting(asUpdatecheckBuilds, 'UpdatecheckBuilds', 0, False);
InitSetting(asUpdatecheckInterval, 'UpdatecheckInterval', 3); InitSetting(asUpdatecheckInterval, 'UpdatecheckInterval', 3);

View File

@ -2,10 +2,10 @@ object loaddataform: Tloaddataform
Left = 212 Left = 212
Top = 111 Top = 111
Caption = 'Import text file' Caption = 'Import text file'
ClientHeight = 494 ClientHeight = 548
ClientWidth = 509 ClientWidth = 513
Color = clBtnFace Color = clBtnFace
Constraints.MinHeight = 530 Constraints.MinHeight = 550
Constraints.MinWidth = 525 Constraints.MinWidth = 525
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
@ -18,12 +18,12 @@ object loaddataform: Tloaddataform
OnResize = FormResize OnResize = FormResize
OnShow = FormShow OnShow = FormShow
DesignSize = ( DesignSize = (
509 513
494) 548)
TextHeight = 14 TextHeight = 14
object btnImport: TButton object btnImport: TButton
Left = 345 Left = 345
Top = 461 Top = 515
Width = 75 Width = 75
Height = 25 Height = 25
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
@ -36,7 +36,7 @@ object loaddataform: Tloaddataform
end end
object btnCancel: TButton object btnCancel: TButton
Left = 426 Left = 426
Top = 461 Top = 515
Width = 75 Width = 75
Height = 25 Height = 25
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
@ -59,23 +59,23 @@ object loaddataform: Tloaddataform
object lblFilename: TLabel object lblFilename: TLabel
Left = 10 Left = 10
Top = 27 Top = 27
Width = 46 Width = 51
Height = 13 Height = 14
Caption = 'Filename:' Caption = 'Filename:'
FocusControl = editFilename FocusControl = editFilename
end end
object lblEncoding: TLabel object lblEncoding: TLabel
Left = 10 Left = 10
Top = 54 Top = 54
Width = 47 Width = 54
Height = 13 Height = 14
Caption = 'Encoding:' Caption = 'Encoding:'
end end
object editFilename: TButtonedEdit object editFilename: TButtonedEdit
Left = 88 Left = 88
Top = 24 Top = 24
Width = 395 Width = 395
Height = 21 Height = 22
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Images = MainForm.VirtualImageListMain Images = MainForm.VirtualImageListMain
RightButton.ImageIndex = 51 RightButton.ImageIndex = 51
@ -90,7 +90,7 @@ object loaddataform: Tloaddataform
Left = 88 Left = 88
Top = 51 Top = 51
Width = 395 Width = 395
Height = 21 Height = 22
Style = csDropDownList Style = csDropDownList
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
DropDownCount = 16 DropDownCount = 16
@ -112,36 +112,36 @@ object loaddataform: Tloaddataform
object lblFieldTerminater: TLabel object lblFieldTerminater: TLabel
Left = 10 Left = 10
Top = 26 Top = 26
Width = 97 Width = 110
Height = 13 Height = 14
Caption = 'Fields terminated by' Caption = 'Fields terminated by'
end end
object lblFieldEncloser: TLabel object lblFieldEncloser: TLabel
Left = 10 Left = 10
Top = 51 Top = 51
Width = 87 Width = 98
Height = 13 Height = 14
Caption = 'Fields enclosed by' Caption = 'Fields enclosed by'
end end
object lblFieldEscaper: TLabel object lblFieldEscaper: TLabel
Left = 10 Left = 10
Top = 75 Top = 75
Width = 85 Width = 95
Height = 13 Height = 14
Caption = 'Fields escaped by' Caption = 'Fields escaped by'
end end
object lblLineTerminator: TLabel object lblLineTerminator: TLabel
Left = 10 Left = 10
Top = 100 Top = 100
Width = 94 Width = 108
Height = 13 Height = 14
Caption = 'Lines terminated by' Caption = 'Lines terminated by'
end end
object editFieldEscaper: TEdit object editFieldEscaper: TEdit
Left = 145 Left = 145
Top = 72 Top = 72
Width = 49 Width = 49
Height = 21 Height = 22
TabOrder = 3 TabOrder = 3
Text = '"' Text = '"'
end end
@ -149,7 +149,7 @@ object loaddataform: Tloaddataform
Left = 145 Left = 145
Top = 48 Top = 48
Width = 49 Width = 49
Height = 21 Height = 22
TabOrder = 1 TabOrder = 1
Text = '"' Text = '"'
end end
@ -157,7 +157,7 @@ object loaddataform: Tloaddataform
Left = 145 Left = 145
Top = 23 Top = 23
Width = 49 Width = 49
Height = 21 Height = 22
TabOrder = 0 TabOrder = 0
Text = ';' Text = ';'
end end
@ -176,7 +176,7 @@ object loaddataform: Tloaddataform
Left = 145 Left = 145
Top = 97 Top = 97
Width = 49 Width = 49
Height = 21 Height = 22
TabOrder = 4 TabOrder = 4
Text = '\r\n' Text = '\r\n'
end end
@ -185,32 +185,32 @@ object loaddataform: Tloaddataform
Left = 8 Left = 8
Top = 98 Top = 98
Width = 209 Width = 209
Height = 135 Height = 175
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
Caption = 'Options' Caption = 'Options'
TabOrder = 1 TabOrder = 1
DesignSize = ( DesignSize = (
209 209
135) 175)
object lblIgnoreLinesCount: TLabel object lblIgnoreLinesCount: TLabel
Left = 143 Left = 143
Top = 26 Top = 26
Width = 21 Width = 23
Height = 13 Height = 14
Caption = 'lines' Caption = 'lines'
end end
object lblIgnoreLines: TLabel object lblIgnoreLines: TLabel
Left = 10 Left = 10
Top = 26 Top = 26
Width = 54 Width = 60
Height = 13 Height = 14
Caption = 'Ignore first' Caption = 'Ignore first'
end end
object updownIgnoreLines: TUpDown object updownIgnoreLines: TUpDown
Left = 121 Left = 121
Top = 23 Top = 23
Width = 16 Width = 16
Height = 21 Height = 22
Associate = editIgnoreLines Associate = editIgnoreLines
Max = 32767 Max = 32767
Position = 1 Position = 1
@ -220,7 +220,7 @@ object loaddataform: Tloaddataform
Left = 88 Left = 88
Top = 23 Top = 23
Width = 33 Width = 33
Height = 21 Height = 22
TabOrder = 0 TabOrder = 0
Text = '1' Text = '1'
end end
@ -257,10 +257,19 @@ object loaddataform: Tloaddataform
Caption = 'Truncate destination table before import' Caption = 'Truncate destination table before import'
TabOrder = 4 TabOrder = 4
end end
object chkKeepDialogOpen: TCheckBox
Left = 10
Top = 138
Width = 196
Height = 17
Anchors = [akLeft, akTop, akRight]
Caption = 'Keep dialog open after import'
TabOrder = 5
end
end end
object grpDuplicates: TRadioGroup object grpDuplicates: TRadioGroup
Left = 8 Left = 8
Top = 239 Top = 279
Width = 209 Width = 209
Height = 123 Height = 123
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
@ -274,9 +283,9 @@ object loaddataform: Tloaddataform
end end
object grpParseMethod: TRadioGroup object grpParseMethod: TRadioGroup
Left = 8 Left = 8
Top = 368 Top = 408
Width = 209 Width = 209
Height = 87 Height = 101
Anchors = [akLeft, akTop, akRight, akBottom] Anchors = [akLeft, akTop, akRight, akBottom]
Caption = 'Method' Caption = 'Method'
ItemIndex = 0 ItemIndex = 0
@ -291,39 +300,39 @@ object loaddataform: Tloaddataform
Left = 223 Left = 223
Top = 239 Top = 239
Width = 278 Width = 278
Height = 216 Height = 270
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
Caption = 'Destination' Caption = 'Destination'
TabOrder = 5 TabOrder = 5
DesignSize = ( DesignSize = (
278 278
216) 270)
object lblDatabase: TLabel object lblDatabase: TLabel
Left = 10 Left = 10
Top = 24 Top = 24
Width = 50 Width = 54
Height = 13 Height = 14
Caption = 'Database:' Caption = 'Database:'
end end
object lblTable: TLabel object lblTable: TLabel
Left = 10 Left = 10
Top = 48 Top = 48
Width = 30 Width = 34
Height = 13 Height = 14
Caption = 'Table:' Caption = 'Table:'
end end
object lblColumns: TLabel object lblColumns: TLabel
Left = 10 Left = 10
Top = 72 Top = 72
Width = 44 Width = 49
Height = 13 Height = 14
Caption = 'Columns:' Caption = 'Columns:'
end end
object comboDatabase: TComboBox object comboDatabase: TComboBox
Left = 112 Left = 112
Top = 21 Top = 21
Width = 156 Width = 156
Height = 21 Height = 22
Style = csDropDownList Style = csDropDownList
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 0 TabOrder = 0
@ -333,7 +342,7 @@ object loaddataform: Tloaddataform
Left = 112 Left = 112
Top = 45 Top = 45
Width = 156 Width = 156
Height = 21 Height = 22
Style = csDropDownList Style = csDropDownList
Anchors = [akLeft, akTop, akRight] Anchors = [akLeft, akTop, akRight]
TabOrder = 1 TabOrder = 1
@ -343,9 +352,9 @@ object loaddataform: Tloaddataform
Left = 112 Left = 112
Top = 72 Top = 72
Width = 153 Width = 153
Height = 129 Height = 183
Anchors = [akLeft, akTop, akRight, akBottom] Anchors = [akLeft, akTop, akRight, akBottom]
ItemHeight = 13 ItemHeight = 14
TabOrder = 2 TabOrder = 2
OnClick = chklistColumnsClick OnClick = chklistColumnsClick
end end
@ -355,7 +364,7 @@ object loaddataform: Tloaddataform
Width = 87 Width = 87
Height = 66 Height = 66
Align = alNone Align = alNone
ButtonWidth = 54 ButtonWidth = 59
Caption = 'ToolBarColMove' Caption = 'ToolBarColMove'
Images = MainForm.VirtualImageListMain Images = MainForm.VirtualImageListMain
List = True List = True

View File

@ -53,6 +53,7 @@ type
chkLocalNumbers: TCheckBox; chkLocalNumbers: TCheckBox;
chkTruncateTable: TCheckBox; chkTruncateTable: TCheckBox;
btnCheckAll: TToolButton; btnCheckAll: TToolButton;
chkKeepDialogOpen: TCheckBox;
const ProgressBarSteps=100; const ProgressBarSteps=100;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure editFilenameChange(Sender: TObject); procedure editFilenameChange(Sender: TObject);
@ -104,6 +105,7 @@ begin
updownIgnoreLines.Position := AppSettings.ReadInt(asCSVImportIgnoreLines); updownIgnoreLines.Position := AppSettings.ReadInt(asCSVImportIgnoreLines);
chkLowPriority.Checked := AppSettings.ReadBool(asCSVImportLowPriority); chkLowPriority.Checked := AppSettings.ReadBool(asCSVImportLowPriority);
chkLocalNumbers.Checked := AppSettings.ReadBool(asCSVImportLocalNumbers); chkLocalNumbers.Checked := AppSettings.ReadBool(asCSVImportLocalNumbers);
chkKeepDialogOpen.Checked := AppSettings.ReadBool(asCSVKeepDialogOpen);
// Uncheck critical "Truncate table" checkbox, to avoid accidental data removal // Uncheck critical "Truncate table" checkbox, to avoid accidental data removal
chkTruncateTable.Checked := False; chkTruncateTable.Checked := False;
grpDuplicates.ItemIndex := AppSettings.ReadInt(asCSVImportDuplicateHandling); grpDuplicates.ItemIndex := AppSettings.ReadInt(asCSVImportDuplicateHandling);
@ -172,6 +174,7 @@ begin
AppSettings.WriteInt(asCSVImportIgnoreLines, updownIgnoreLines.Position); AppSettings.WriteInt(asCSVImportIgnoreLines, updownIgnoreLines.Position);
AppSettings.WriteBool(asCSVImportLowPriority, chkLowPriority.Checked); AppSettings.WriteBool(asCSVImportLowPriority, chkLowPriority.Checked);
AppSettings.WriteBool(asCSVImportLocalNumbers, chkLocalNumbers.Checked); AppSettings.WriteBool(asCSVImportLocalNumbers, chkLocalNumbers.Checked);
AppSettings.WriteBool(asCSVKeepDialogOpen, chkKeepDialogOpen.Checked);
AppSettings.WriteInt(asCSVImportDuplicateHandling, grpDuplicates.ItemIndex); AppSettings.WriteInt(asCSVImportDuplicateHandling, grpDuplicates.ItemIndex);
AppSettings.WriteInt(asCSVImportParseMethod, grpParseMethod.ItemIndex); AppSettings.WriteInt(asCSVImportParseMethod, grpParseMethod.ItemIndex);
end; end;
@ -330,6 +333,9 @@ begin
FLineTerm := FConnection.UnescapeString(editLineTerminator.Text); FLineTerm := FConnection.UnescapeString(editLineTerminator.Text);
FEscp := FConnection.UnescapeString(editFieldEscaper.Text); FEscp := FConnection.UnescapeString(editFieldEscaper.Text);
if chkKeepDialogOpen.Checked then
ModalResult := mrNone;
try try
case grpParseMethod.ItemIndex of case grpParseMethod.ItemIndex of
0: ServerParse(Sender); 0: ServerParse(Sender);
@ -362,6 +368,9 @@ begin
end; end;
end; end;
if ModalResult = mrNone then
btnCancel.Caption := _('Close');
Mainform.ShowStatusMsg; Mainform.ShowStatusMsg;
MainForm.DisableProgress; MainForm.DisableProgress;
Screen.Cursor := crDefault; Screen.Cursor := crDefault;