From 84c638f0de3f21ea5feb43d03ff2ede305d05dfd Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 30 May 2010 23:19:23 +0000 Subject: [PATCH] Prefer VCL function StripHotkey() over StringReplace --- source/main.pas | 25 +++++++++++-------------- source/options.pas | 4 ++-- source/table_editor.pas | 3 +-- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/source/main.pas b/source/main.pas index 75ba3e65..04b12e34 100644 --- a/source/main.pas +++ b/source/main.pas @@ -1053,7 +1053,7 @@ var flushwhat: String; begin flushwhat := UpperCase(TAction(Sender).Caption); - delete(flushwhat, pos('&', flushwhat), 1); + flushwhat := StripHotkey(flushwhat); try Connection.Query('FLUSH ' + flushwhat); if Sender = actFlushTableswithreadlock then begin @@ -3129,22 +3129,19 @@ end; procedure TMainform.popupQueryLoadClick( sender: TObject ); var - filename : String; - p : Integer; + Filename: String; + p: Integer; begin // Click on the popupQueryLoad - filename := (Sender as TMenuItem).Caption; - if Pos( '\', filename ) = 0 then - begin // assuming we load a snippet - filename := DirnameSnippets + filename + '.sql'; - end - else - begin // assuming we load a file from the recent-list - p := Pos( ' ', filename ) + 1; - filename := Copy(filename, p, Length(filename)); + Filename := (Sender as TMenuItem).Caption; + Filename := StripHotkey(Filename); + if Pos('\', Filename) = 0 then // assuming we load a snippet + Filename := DirnameSnippets + Filename + '.sql' + else begin // assuming we load a file from the recent-list + p := Pos(' ', Filename) + 1; + filename := Copy(Filename, p, Length(Filename)); end; - filename := Stringreplace(filename, '&', '', [rfReplaceAll]); - QueryLoad( filename ); + QueryLoad(Filename); end; diff --git a/source/options.pas b/source/options.pas index 1c7d904b..9c6829ad 100644 --- a/source/options.pas +++ b/source/options.pas @@ -11,7 +11,7 @@ interface uses Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls, SynEditHighlighter, SynHighlighterSQL, - SynEdit, SynMemo, VirtualTrees, SynEditKeyCmds, ActnList, SynEditMiscClasses, StdActns; + SynEdit, SynMemo, VirtualTrees, SynEditKeyCmds, ActnList, SynEditMiscClasses, StdActns, Menus; type TShortcutItemData = record @@ -734,7 +734,7 @@ begin end; end else if Assigned(Data.Action) then begin CellText := Data.Action.Caption; - CellText := StringReplace(CellText, '&', '', [rfReplaceAll]); + CellText := StripHotkey(CellText); end; end; end; diff --git a/source/table_editor.pas b/source/table_editor.pas index a525f1c6..8dc09e1d 100644 --- a/source/table_editor.pas +++ b/source/table_editor.pas @@ -1876,8 +1876,7 @@ begin Node := listColumns.GetNextSelected(Node); end; if Item.Parent = menuCreateIndex then begin - // Remove auto hotkeys - NewType := StringReplace(Item.Caption, '&', '', [rfReplaceAll]); + NewType := StripHotkey(Item.Caption); // Avoid creating a second key with the same columns for i:=0 to FKeys.Count-1 do begin TblKey := FKeys[i];