New Feature. Add SQL snippets to query helpers in a new tab

This commit is contained in:
Ansgar Becker
2007-07-14 18:03:27 +00:00
parent f39222fea5
commit f49e9f9e41
2 changed files with 31 additions and 6 deletions

View File

@@ -1006,7 +1006,6 @@ object MDIChild: TMDIChild
Width = 160
Height = 24
Align = alBottom
AutoScroll = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
@@ -1018,7 +1017,8 @@ object MDIChild: TMDIChild
Tabs.Strings = (
'Cols'
'SQL fn'
'SQL kw')
'SQL kw'
'Snippets')
TabIndex = 0
OnChange = tabsetQueryHelpersChange
end

View File

@@ -489,7 +489,7 @@ type
lastUsedDB : String;
UserQueryFired : Boolean;
CachedTableLists : TStringList;
QueryHelpersSelectedItems : Array[0..2] of Integer;
QueryHelpersSelectedItems : Array[0..3] of Integer;
function GetQueryRunning: Boolean;
procedure SetQueryRunning(running: Boolean);
@@ -4329,22 +4329,32 @@ procedure TMDIChild.SynMemoQueryDragDrop(Sender, Source: TObject; X,
var
src : TControl;
Text : String;
LoadText : Boolean;
begin
// dropping a TTreeNode into the query-memo
SynMemoQuery.UndoList.AddGroupBreak;
src := Source as TControl;
Text := 'Error: Unspecified source control in drag''n drop operation!';
LoadText := True;
// Check for allowed controls as source has already
// been performed in OnDragOver. So, only do typecasting here.
if src is TTreeView then
begin
Text := (src as TTreeView).Selected.Text;
end
else if src is TListBox then
else if src = lboxQueryHelpers then
begin
Text := (src as TListBox).Items[(src as TListBox).ItemIndex];
if tabsetQueryHelpers.TabIndex = 3 then
begin
QueryLoad( DIRNAME_SNIPPETS + Text, False );
LoadText := False;
end;
end;
SynMemoQuery.SelText := Text;
// Only insert text if no previous action did the job.
// Should be false when dropping a snippet-file here
if LoadText then
SynMemoQuery.SelText := Text;
SynMemoQuery.UndoList.AddGroupBreak;
end;
@@ -5595,6 +5605,11 @@ begin
lboxQueryHelpers.Items := MYSQL_KEYWORDS;
end;
3: // SQL Snippets
begin
lboxQueryHelpers.Items := getFilesFromDir( DIRNAME_SNIPPETS, '*.sql' );
end;
end;
// Restore last selected item in tab
@@ -5615,8 +5630,18 @@ end;
memo at doubleclick
}
procedure TMDIChild.lboxQueryHelpersDblClick(Sender: TObject);
var
itemtext : String;
begin
SynMemoQuery.SelText := lboxQueryHelpers.Items[lboxQueryHelpers.ItemIndex];
itemtext := lboxQueryHelpers.Items[lboxQueryHelpers.ItemIndex];
case tabsetQueryHelpers.TabIndex of
3: // Load snippet file <20>nto query-memo
QueryLoad( DIRNAME_SNIPPETS + itemtext, False );
else // For all other tabs just insert the item from the list
SynMemoQuery.SelText := itemtext;
end;
SynMemoQuery.SetFocus;
end;