From c130db80a78a4ff755f94fd30ede938c2e2f9b84 Mon Sep 17 00:00:00 2001 From: "meffi@lab313.ru" Date: Wed, 7 May 2014 00:42:00 +0000 Subject: [PATCH] --- tim2view.lps | 44 +++++++++++++++++++++++--------------------- todos.inc | 3 ++- umain.lfm | 5 +++-- umain.pas | 19 ++----------------- uscanresult.pas | 19 ++++++++++++++++++- uscanthread.pas | 17 ++++++++--------- 6 files changed, 56 insertions(+), 51 deletions(-) diff --git a/tim2view.lps b/tim2view.lps index c13609f..ab06667 100644 --- a/tim2view.lps +++ b/tim2view.lps @@ -23,8 +23,8 @@ - - + + @@ -48,10 +48,10 @@ - + - - + + @@ -59,7 +59,7 @@ - + @@ -70,7 +70,7 @@ - + @@ -81,7 +81,7 @@ - + @@ -92,10 +92,10 @@ - + - - + + @@ -103,11 +103,10 @@ - - + - - + + @@ -115,7 +114,7 @@ - + @@ -126,7 +125,7 @@ - + @@ -145,20 +144,23 @@ + + - + + - + - + @@ -187,7 +189,7 @@ - + diff --git a/todos.inc b/todos.inc index cac4430..8231534 100644 --- a/todos.inc +++ b/todos.inc @@ -1,2 +1,3 @@ { TODO : Zooming? } -{ TODO : Add different PNG output for Export. } +{ TODO : Add file to filelist } +{ TODO : StartScan - remove refs to umain } \ No newline at end of file diff --git a/umain.lfm b/umain.lfm index b7ed2e7..9f1bb67 100644 --- a/umain.lfm +++ b/umain.lfm @@ -584,8 +584,9 @@ object frmMain: TfrmMain Align = alClient Columns = < item + AutoSize = True Caption = '# / 0' - Width = 60 + Width = 41 end item Alignment = taCenter @@ -603,7 +604,7 @@ object frmMain: TfrmMain Alignment = taCenter AutoSize = True Caption = 'W x H' - Width = 91 + Width = 128 end> ColumnClick = False GridLines = True diff --git a/umain.pas b/umain.pas index e63c86f..4ad1b6b 100644 --- a/umain.pas +++ b/umain.pas @@ -179,7 +179,6 @@ type { public declarations } ScanResults: TScanResultList; //List of finished scan results ScanThreads: TScanThreadList; //List of currently started scans - function CheckForFileOpened(const FileName: string): boolean; end; var @@ -774,20 +773,6 @@ begin Result^.HEAD^.bBPP := Integer(cbbBitMode.Tag); end; -function TfrmMain.CheckForFileOpened(const FileName: string): boolean; -var - I: Integer; -begin - Result := False; - - for I := 1 to ScanResults.Count do - if ScanResults[I - 1].ScanFile = FileName then - begin - Result := True; - Exit; - end; -end; - procedure TfrmMain.ScanPath(const Path: string); begin if Path = '' then Exit; @@ -806,7 +791,7 @@ begin LastDir := ExtractFilePath(FileName); Settings.LastDir := LastDir; - if CheckForFileOpened(FileName) then + if CheckForFileOpened(@ScanResults, FileName) then begin cbbFiles.ItemIndex := cbbFiles.Items.IndexOf(FileName); actChangeFile.Execute; @@ -818,7 +803,7 @@ begin if not Boolean(actStopScan.Tag) then begin - ScanThreads.Add(TScanThread.Create(FileName, GetImageScan(FileName))); + ScanThreads.Add(TScanThread.Create(FileName, GetImageScan(FileName), @ScanResults)); ScanThreads.Last.FreeOnTerminate := True; ScanThreads.Last.Priority := tpNormal; ScanThreads.Last.OnTerminate := @ScanFinished; diff --git a/uscanresult.pas b/uscanresult.pas index 73e65b0..76230cd 100644 --- a/uscanresult.pas +++ b/uscanresult.pas @@ -39,6 +39,9 @@ type property ScanTim[index: Integer]: TTimInfo read fGetTim write fSetTim; end; TScanResultList = specialize TFPGObjectList; + PScanResultList = ^TScanResultList; + + function CheckForFileOpened(ScanResults: PScanResultList; const FileName: string): boolean; implementation @@ -77,4 +80,18 @@ begin pTims[Index] := Value; end; -end. +function CheckForFileOpened(ScanResults: PScanResultList; const FileName: string): boolean; +var + I: Integer; +begin + Result := False; + + for I := 1 to ScanResults^.Count do + if ScanResults^[I - 1].ScanFile = FileName then + begin + Result := True; + Exit; + end; +end; + +end. \ No newline at end of file diff --git a/uscanthread.pas b/uscanthread.pas index db8f1be..d346b3c 100644 --- a/uscanthread.pas +++ b/uscanthread.pas @@ -10,6 +10,7 @@ type private { Private declarations } pScanResult: TScanResult; + pResults: PScanResultList; pFileSize: Integer; pFilePos: Integer; pStatusText: string; @@ -27,7 +28,7 @@ type protected procedure Execute; override; public - constructor Create(const FileToScan: string; ImageScan: boolean); + constructor Create(const FileToScan: string; ImageScan: boolean; Results: PScanResultList); //property Started: boolean read pStarted write pStarted; property StopScan: boolean read pStopScan write pStopScan; end; @@ -44,7 +45,7 @@ const { TScanThread } -constructor TScanThread.Create(const FileToScan: string; ImageScan: boolean); +constructor TScanThread.Create(const FileToScan: string; ImageScan: boolean; Results: PScanResultList); begin inherited Create(True); FreeOnTerminate := True; @@ -57,6 +58,7 @@ begin pScanResult := TScanResult.Create; pScanResult.ScanFile := FileToScan; pScanResult.IsImage := ImageScan; + pResults := Results; end; procedure TScanThread.AddResult(TIM: PTIM); @@ -170,7 +172,7 @@ begin pFilePos := 0; pStatusText := ''; - Synchronize(@FinishScan); + FinishScan; end; procedure TScanThread.FinishScan; @@ -184,11 +186,8 @@ begin Exit; end; - if not frmMain.CheckForFileOpened(pScanResult.ScanFile) then - begin - frmMain.ScanResults.Add(pScanResult); - frmMain.cbbFiles.Items.Add(pScanResult.ScanFile); - end + if not CheckForFileOpened(pResults, pScanResult.ScanFile) then + pResults^.Add(pScanResult) else pScanResult.Free; end; @@ -230,4 +229,4 @@ begin end; end; -end. +end. \ No newline at end of file