Code cosmetic:

* Move "const" + "type" fragments to a unified place.
* Use mixed case instead of all upper in a variable
* No need to format the "uses" list vertically
* Move helper InheritFont() to helpers.pas
This commit is contained in:
Ansgar Becker
2009-08-30 06:27:53 +00:00
parent 0ec73d7727
commit 1d6ff80121
2 changed files with 52 additions and 66 deletions

View File

@ -92,6 +92,13 @@ type
TLineBreaks = (lbsNone, lbsWindows, lbsUnix, lbsMac, lbsWide, lbsMixed); TLineBreaks = (lbsNone, lbsWindows, lbsUnix, lbsMac, lbsWide, lbsMixed);
TMyKey = record
Name : String;
_type : String;
Columns : TWideStringList;
SubParts : TWideStringList;
end;
{$I const.inc} {$I const.inc}
function implodestr(seperator: WideString; a: TWideStringList) :WideString; function implodestr(seperator: WideString; a: TWideStringList) :WideString;
@ -184,6 +191,7 @@ type
procedure RestoreSyneditStyles(Highlighter: TSynCustomHighlighter); procedure RestoreSyneditStyles(Highlighter: TSynCustomHighlighter);
procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil); procedure SelectNode(VT: TVirtualStringTree; idx: Cardinal; ParentNode: PVirtualNode=nil);
function DateBackFriendlyCaption(d: TDateTime): String; function DateBackFriendlyCaption(d: TDateTime): String;
procedure InheritFont(AFont: TFont);
var var
MainReg : TRegistry; MainReg : TRegistry;
@ -3049,6 +3057,14 @@ begin
end; end;
end; end;
procedure InheritFont(AFont: TFont);
begin
AFont.Name := Mainform.Font.Name;
AFont.Size := Mainform.Font.Size;
end;
end. end.

View File

@ -25,16 +25,6 @@ uses
WideStrUtils, ZDbcLogging, ExtActns, CommCtrl, routine_editor, options, WideStrUtils, ZDbcLogging, ExtActns, CommCtrl, routine_editor, options,
Contnrs, PngSpeedButton, connections; Contnrs, PngSpeedButton, connections;
const
// The InnoDB folks are raging over the lack of count(*) support
// in the storage engine. To avoid count(*), the first of these
// constants decide how many rows the data area should estimate
// in any table. The second value decides how many percent above the
// number of seen (or simulated) rows the scrollbar should project.
SIMULATE_INITIAL_ROWS = 10000;
SIMULATE_MORE_ROWS = 20;
MSG_UPDATECHECK = WM_USER + 1;
MSG_ABOUT = WM_USER + 2;
type type
TQueryTab = class(TObject) TQueryTab = class(TObject)
@ -56,6 +46,13 @@ type
GridResult: TGridResult; GridResult: TGridResult;
end; end;
// Represents errors already "handled" (shown to user),
// which can thus safely be ignored.
THandledSQLError = class(Exception)
end;
PMethod = ^TMethod;
TMainForm = class(TForm) TMainForm = class(TForm)
MainMenu1: TMainMenu; MainMenu1: TMainMenu;
File1: TMenuItem; File1: TMenuItem;
@ -910,9 +907,6 @@ type
end; end;
procedure InheritFont(AFont: TFont);
var var
MainForm : TMainForm; MainForm : TMainForm;
AppVersion : String = 'x.y'; AppVersion : String = 'x.y';
@ -920,7 +914,7 @@ var
FullAppVersion : String; FullAppVersion : String;
DirnameCommonAppData, DirnameCommonAppData,
DirnameUserAppData, DirnameUserAppData,
DIRNAME_SNIPPETS, DirnameSnippets,
DirnameSessionLogs : String; DirnameSessionLogs : String;
const const
@ -929,54 +923,30 @@ const
ICON_MYSELF_DISCONNECTED = -1; ICON_MYSELF_DISCONNECTED = -1;
ICON_OTHER_CONNECTED = 36; ICON_OTHER_CONNECTED = 36;
ICON_OTHER_DISCONNECTED = -1; ICON_OTHER_DISCONNECTED = -1;
// The InnoDB folks are raging over the lack of count(*) support
// in the storage engine. To avoid count(*), the first of these
// constants decide how many rows the data area should estimate
// in any table. The second value decides how many percent above the
// number of seen (or simulated) rows the scrollbar should project.
SIMULATE_INITIAL_ROWS = 10000;
SIMULATE_MORE_ROWS = 20;
MSG_UPDATECHECK = WM_USER + 1;
MSG_ABOUT = WM_USER + 2;
{$I const.inc} {$I const.inc}
type TMyKey = record
Name : String;
_type : String;
Columns : TWideStringList;
SubParts : TWideStringList;
end;
type
// Represents errors already "handled" (shown to user),
// which can thus safely be ignored.
THandledSQLError = class(Exception)
end;
implementation implementation
uses uses
About, About, exportsql, loaddata, printlist, copytable, insertfiles, Threading,
exportsql, mysql_structures, UpdateCheck, uVistaFuncs, runsqlfile, column_selection,
loaddata, data_sorting, grideditlinks, dataviewsave;
printlist,
copytable,
insertfiles,
Threading,
mysql_structures,
UpdateCheck,
uVistaFuncs,
runsqlfile,
column_selection,
data_sorting,
grideditlinks,
dataviewsave;
type
PMethod = ^TMethod;
{$R *.DFM} {$R *.DFM}
procedure InheritFont(AFont: TFont);
begin
AFont.Name := Mainform.Font.Name;
AFont.Size := Mainform.Font.Size;
end;
procedure TMainForm.HandleWMComplete(var msg: TMessage); procedure TMainForm.HandleWMComplete(var msg: TMessage);
begin begin
HandleWMCompleteMessage(msg); HandleWMCompleteMessage(msg);
@ -1304,7 +1274,7 @@ begin
ForceDirectories(DirnameUserAppData); ForceDirectories(DirnameUserAppData);
// Folder which contains snippet-files // Folder which contains snippet-files
DIRNAME_SNIPPETS := DirnameCommonAppData + 'Snippets\'; DirnameSnippets := DirnameCommonAppData + 'Snippets\';
// Folder for session logfiles // Folder for session logfiles
DirnameSessionLogs := DirnameUserAppData + 'Sessionlogs\'; DirnameSessionLogs := DirnameUserAppData + 'Sessionlogs\';
@ -2893,7 +2863,7 @@ begin
if Copy( snippetname, Length(snippetname)-4, 4 ) <> '.sql' then if Copy( snippetname, Length(snippetname)-4, 4 ) <> '.sql' then
snippetname := snippetname + '.sql'; snippetname := snippetname + '.sql';
// cleanup snippetname from special characters // cleanup snippetname from special characters
snippetname := DIRNAME_SNIPPETS + goodfilename(snippetname); snippetname := DirnameSnippets + goodfilename(snippetname);
if FileExists( snippetname ) then if FileExists( snippetname ) then
begin begin
if MessageDlg( 'Overwrite existing snippet '+snippetname+'?', mtConfirmation, [mbOK, mbCancel], 0 ) <> mrOK then if MessageDlg( 'Overwrite existing snippet '+snippetname+'?', mtConfirmation, [mbOK, mbCancel], 0 ) <> mrOK then
@ -3011,7 +2981,7 @@ begin
popupQueryLoad.Items.Clear; popupQueryLoad.Items.Clear;
// Snippets // Snippets
snippets := getFilesFromDir( DIRNAME_SNIPPETS, '*.sql', true ); snippets := getFilesFromDir( DirnameSnippets, '*.sql', true );
snippetsfolder := TMenuItem.Create( popupQueryLoad ); snippetsfolder := TMenuItem.Create( popupQueryLoad );
snippetsfolder.Caption := 'Snippets'; snippetsfolder.Caption := 'Snippets';
popupQueryLoad.Items.Add(snippetsfolder); popupQueryLoad.Items.Add(snippetsfolder);
@ -3067,7 +3037,7 @@ begin
filename := (Sender as TMenuItem).Caption; filename := (Sender as TMenuItem).Caption;
if Pos( '\', filename ) = 0 then if Pos( '\', filename ) = 0 then
begin // assuming we load a snippet begin // assuming we load a snippet
filename := DIRNAME_SNIPPETS + filename + '.sql'; filename := DirnameSnippets + filename + '.sql';
end end
else else
begin // assuming we load a file from the recent-list begin // assuming we load a file from the recent-list
@ -5000,7 +4970,7 @@ begin
else if (src = ActiveQueryHelpers) and (ActiveQueryHelpers.ItemIndex > -1) then begin else if (src = ActiveQueryHelpers) and (ActiveQueryHelpers.ItemIndex > -1) then begin
// Snippets tab // Snippets tab
if tabsetQueryHelpers.TabIndex = 3 then begin if tabsetQueryHelpers.TabIndex = 3 then begin
QueryLoad( DIRNAME_SNIPPETS + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', False ); QueryLoad( DirnameSnippets + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', False );
LoadText := False; LoadText := False;
// All other tabs // All other tabs
end else begin end else begin
@ -5145,7 +5115,7 @@ begin
begin begin
RunSQLFileWindow( Self, filename ); RunSQLFileWindow( Self, filename );
// Add filename to history menu // Add filename to history menu
if Pos( DIRNAME_SNIPPETS, filename ) = 0 then if Pos( DirnameSnippets, filename ) = 0 then
AddOrRemoveFromQueryLoadHistory( filename, true ); AddOrRemoveFromQueryLoadHistory( filename, true );
// Don't load into editor // Don't load into editor
Abort; Abort;
@ -5164,7 +5134,7 @@ begin
Screen.Cursor := crHourGlass; Screen.Cursor := crHourGlass;
try try
filecontent := ReadTextfile(filename); filecontent := ReadTextfile(filename);
if Pos( DIRNAME_SNIPPETS, filename ) = 0 then if Pos( DirnameSnippets, filename ) = 0 then
AddOrRemoveFromQueryLoadHistory( filename, true ); AddOrRemoveFromQueryLoadHistory( filename, true );
FillPopupQueryLoad; FillPopupQueryLoad;
if not QueryTabActive then if not QueryTabActive then
@ -5820,7 +5790,7 @@ begin
3: // SQL Snippets 3: // SQL Snippets
begin begin
ActiveQueryHelpers.MultiSelect := False; ActiveQueryHelpers.MultiSelect := False;
Files := getFilesFromDir( DIRNAME_SNIPPETS, '*.sql', true ); Files := getFilesFromDir( DirnameSnippets, '*.sql', true );
for i := 0 to Files.Count - 1 do for i := 0 to Files.Count - 1 do
ActiveQueryHelpers.Items.Add(Files[i]); ActiveQueryHelpers.Items.Add(Files[i]);
Files.Free; Files.Free;
@ -5863,7 +5833,7 @@ begin
case ActiveQueryTabset.TabIndex of case ActiveQueryTabset.TabIndex of
3: // Load snippet file <20>nto query-memo 3: // Load snippet file <20>nto query-memo
QueryLoad( DIRNAME_SNIPPETS + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', False ); QueryLoad( DirnameSnippets + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', False );
else // For all other tabs just insert the item from the list else // For all other tabs just insert the item from the list
ActiveQueryMemo.SelText := text; ActiveQueryMemo.SelText := text;
end; end;
@ -5925,7 +5895,7 @@ begin
if ActiveQueryHelpers.ItemIndex = -1 then if ActiveQueryHelpers.ItemIndex = -1 then
abort; abort;
snippetfile := DIRNAME_SNIPPETS + ActiveQueryHelpers.Items[ ActiveQueryHelpers.ItemIndex ] + '.sql'; snippetfile := DirnameSnippets + ActiveQueryHelpers.Items[ ActiveQueryHelpers.ItemIndex ] + '.sql';
if MessageDlg( 'Delete snippet file? ' + CRLF + snippetfile, mtConfirmation, [mbOk, mbCancel], 0) = mrOk then if MessageDlg( 'Delete snippet file? ' + CRLF + snippetfile, mtConfirmation, [mbOk, mbCancel], 0) = mrOk then
begin begin
Screen.Cursor := crHourGlass; Screen.Cursor := crHourGlass;
@ -5951,7 +5921,7 @@ end;
} }
procedure TMainForm.menuInsertSnippetAtCursorClick(Sender: TObject); procedure TMainForm.menuInsertSnippetAtCursorClick(Sender: TObject);
begin begin
QueryLoad( DIRNAME_SNIPPETS + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', False ); QueryLoad( DirnameSnippets + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', False );
end; end;
@ -5960,7 +5930,7 @@ end;
} }
procedure TMainForm.menuLoadSnippetClick(Sender: TObject); procedure TMainForm.menuLoadSnippetClick(Sender: TObject);
begin begin
QueryLoad( DIRNAME_SNIPPETS + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', True ); QueryLoad( DirnameSnippets + ActiveQueryHelpers.Items[ActiveQueryHelpers.ItemIndex] + '.sql', True );
end; end;
@ -5972,14 +5942,14 @@ begin
// Normally the snippets folder is created at installation. But it sure // Normally the snippets folder is created at installation. But it sure
// can be the case that it has been deleted or that the application was // can be the case that it has been deleted or that the application was
// not installed properly. Ask if we should create the folder now. // not installed properly. Ask if we should create the folder now.
if DirectoryExists( DIRNAME_SNIPPETS ) then if DirectoryExists( DirnameSnippets ) then
ShellExec( '', DIRNAME_SNIPPETS ) ShellExec( '', DirnameSnippets )
else else
if MessageDlg( 'Snippets folder does not exist: ' + DIRNAME_SNIPPETS + CRLF + CRLF + 'This folder is normally created when you install '+appname+'.' + CRLF + CRLF + 'Shall it be created now?', if MessageDlg( 'Snippets folder does not exist: ' + DirnameSnippets + CRLF + CRLF + 'This folder is normally created when you install '+appname+'.' + CRLF + CRLF + 'Shall it be created now?',
mtWarning, [mbYes, mbNo], 0 ) = mrYes then mtWarning, [mbYes, mbNo], 0 ) = mrYes then
try try
Screen.Cursor := crHourglass; Screen.Cursor := crHourglass;
ForceDirectories( DIRNAME_SNIPPETS ); ForceDirectories( DirnameSnippets );
finally finally
Screen.Cursor := crDefault; Screen.Cursor := crDefault;
end; end;