mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 09:42:46 +02:00
PoChecker: simplified code by removing TPoTestOptions set (which had only one element) and directly analyzing LangID value instead
git-svn-id: trunk@62071 -
This commit is contained in:
parent
e216e6cfec
commit
6e821e62a0
@ -69,7 +69,6 @@ type
|
||||
procedure OnTestEnd(const {%H-}ATestName: string; const {%H-}ErrorCount: integer);
|
||||
procedure FillTestListBox;
|
||||
function GetTestTypesFromListBox: TPoTestTypes;
|
||||
function GetTestOptions: TPoTestOptions;
|
||||
procedure SetTestTypeCheckBoxes(TestTypes: TPoTestTypes);
|
||||
procedure ShowError(const Msg: string);
|
||||
procedure ScanDirectory(ADir: String);
|
||||
@ -298,16 +297,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPoCheckerForm.GetTestOptions: TPoTestOptions;
|
||||
var
|
||||
ALangID: TLangID;
|
||||
begin
|
||||
Result := [];
|
||||
ALangID := LangFilterIndexToLangID(LangFilter.ItemIndex);
|
||||
if ALangID = lang_all then
|
||||
Include(Result,ptoFindAllChildren);
|
||||
end;
|
||||
|
||||
procedure TPoCheckerForm.SetTestTypeCheckBoxes(TestTypes: TPoTestTypes);
|
||||
var
|
||||
Typ: TPoTestType;
|
||||
@ -412,7 +401,6 @@ end;
|
||||
procedure TPoCheckerForm.RunSelectedTests;
|
||||
var
|
||||
TestTypes: TPoTestTypes;
|
||||
TestOptions: TPoTestOptions;
|
||||
TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer;
|
||||
TotalPercTranslated: Double;
|
||||
ResultDlg: TResultDlgForm;
|
||||
@ -424,12 +412,10 @@ begin
|
||||
ShowError(sNoTestSelected);
|
||||
Exit;
|
||||
end;
|
||||
TestOptions := GetTestOptions;
|
||||
Application.ProcessMessages;
|
||||
mr := mrNone;
|
||||
try
|
||||
PoFamilyList.TestTypes := TestTypes;
|
||||
PoFamilyList.TestOptions := TestOptions;
|
||||
|
||||
PoFamilyList.RunTests(TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount, TotalPercTranslated);
|
||||
|
||||
@ -442,7 +428,6 @@ begin
|
||||
|
||||
ResultDlg := TResultDlgForm.Create(nil);
|
||||
try
|
||||
ResultDlg.FTestOptions := TestOptions;
|
||||
ResultDlg.FTotalTranslated := TotalTranslatedCount;
|
||||
ResultDlg.FTotalUntranslated := TotalUntranslatedCount;
|
||||
ResultDlg.FTotalFuzzy := TotalFuzzyCount;
|
||||
@ -572,7 +557,6 @@ begin
|
||||
ID := LangFilterIndexToLangID(LangFilter.ItemIndex);
|
||||
FPoCheckerSettings.LangFilterLanguageAbbr := LanguageAbbr[ID];
|
||||
FPoCheckerSettings.TestTypes := GetTestTypesFromListBox;
|
||||
FPoCheckerSettings.TestOptions := GetTestOptions;
|
||||
FPoCheckerSettings.MainFormWindowState := WindowState;
|
||||
if (WindowState = wsNormal) then
|
||||
FPoCheckerSettings.MainFormGeometry := BoundsRect
|
||||
|
@ -29,7 +29,6 @@ type
|
||||
FResultsFormWindowState: TWindowState;
|
||||
FSelectDirectoryFilename: String;
|
||||
FTestTypes: TPoTestTypes;
|
||||
FTestOptions: TPoTestOptions;
|
||||
FMasterPoList: TStringList;
|
||||
FMasterPoSelList: TStringList;
|
||||
FMainFormGeometry: TRect;
|
||||
@ -40,7 +39,6 @@ type
|
||||
function GetMasterPoList: TStrings;
|
||||
function GetMasterPoSelList: TStrings;
|
||||
function LoadTestTypes: TPoTestTypes;
|
||||
function LoadTestOptions: TPoTestOptions;
|
||||
procedure LoadWindowsGeometry;
|
||||
procedure LoadDisableAntiAliasing;
|
||||
function LoadExternalEditorName: String;
|
||||
@ -50,7 +48,6 @@ type
|
||||
procedure LoadMasterPoList(List: TStrings);
|
||||
procedure LoadMasterPoSelList(List: TStrings);
|
||||
procedure SaveTestTypes;
|
||||
procedure SaveTestOptions;
|
||||
procedure SaveWindowsGeometry;
|
||||
procedure SaveDisableAntialiasing;
|
||||
procedure SaveExternalEditorName;
|
||||
@ -72,7 +69,6 @@ type
|
||||
|
||||
property Filename: String read FFilename;
|
||||
property TestTypes: TPoTestTypes read FTestTypes write FTestTypes;
|
||||
property TestOptions: TPoTestOptions read FTestOptions write FTestOptions;
|
||||
property ExternalEditorName: String read FExternalEditorName write FExternalEditorName;
|
||||
property MasterPoList: TStrings read GetMasterPoList write SetMasterPoList;
|
||||
property MasterPoSelList: TStrings read GetMasterPoSelList write SetMasterPoSelList;
|
||||
@ -89,7 +85,6 @@ type
|
||||
end;
|
||||
|
||||
function DbgS(PoTestTypes: TPoTestTypes): String; overload;
|
||||
function DbgS(PoTestOpts: TPoTestOptions): String; overload;
|
||||
function FitToRect(const ARect, FitIn: TRect): TRect;
|
||||
function IsDefaultRect(ARect: TRect): Boolean;
|
||||
function IsValidRect(ARect: TRect): Boolean;
|
||||
@ -154,9 +149,6 @@ const
|
||||
'CheckMissingIdentifiers',
|
||||
'CheckForMismatchesInUntranslatedStrings'
|
||||
);
|
||||
TestoptionNames: array[TPoTestOption] of String = (
|
||||
'FindAllChildren'
|
||||
);
|
||||
|
||||
pSelectDirectoryFilename = 'SelectDirectoryFilename/';
|
||||
pLangFilter = 'LanguageFilter/';
|
||||
@ -186,20 +178,6 @@ begin
|
||||
Result := Result + ']';
|
||||
end;
|
||||
|
||||
function DbgS(PoTestOpts: TPoTestOptions): String; overload;
|
||||
var
|
||||
Opt: TPoTestOption;
|
||||
begin
|
||||
Result := '[';
|
||||
for Opt := Low(TPotestOption) to High(TPoTestOption) do
|
||||
begin
|
||||
if (Opt in PoTestOpts) then Result := Result + TestOptionNames[opt];
|
||||
end;
|
||||
if (Result[Length(Result)] = ',') then System.Delete(Result,Length(Result),1);
|
||||
Result := Result + ']';
|
||||
end;
|
||||
|
||||
|
||||
|
||||
{ TPoCheckerSettings }
|
||||
{$ifdef pocheckerstandalone}
|
||||
@ -286,21 +264,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TPoCheckerSettings.LoadTestOptions: TPoTestOptions;
|
||||
var
|
||||
opt: TPoTestOption;
|
||||
Name: String;
|
||||
B: Boolean;
|
||||
begin
|
||||
Result := [];
|
||||
for opt := Low(TPoTestOption) to High(TPoTestOption) do
|
||||
begin
|
||||
Name := TestOptionNames[opt];
|
||||
B := FConfig.GetValue(pTestOptions + Name + '/Value',False);
|
||||
if B then Result := Result + [opt];
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerSettings.LoadWindowsGeometry;
|
||||
function IntToWindowState(WSInt: Integer): TWindowState;
|
||||
begin
|
||||
@ -449,18 +412,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerSettings.SaveTestOptions;
|
||||
var
|
||||
topt: TPoTestOption;
|
||||
Name: String;
|
||||
begin
|
||||
for topt := Low(TPoTestOptions) to High(TPoTestoptions) do
|
||||
begin
|
||||
Name := TestOptionNames[topt];
|
||||
FConfig.SetDeleteValue(pTestOptions + Name + '/Value',(topt in FTestOptions),False);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPoCheckerSettings.SaveWindowsGeometry;
|
||||
begin
|
||||
FConfig.SetDeleteValue(pWindowsGeometry+'MainForm/Value',FMainFormGeometry,DefaultRect);
|
||||
@ -552,7 +503,6 @@ end;
|
||||
procedure TPoCheckerSettings.ResetAllProperties;
|
||||
begin
|
||||
FTestTypes := [];
|
||||
FTestOptions := [];
|
||||
FMainFormGeometry := DefaultRect;
|
||||
FGraphFormGeometry := DefaultRect;
|
||||
FResultsFormGeometry := DefaultRect;
|
||||
@ -610,7 +560,6 @@ procedure TPoCheckerSettings.LoadConfig;
|
||||
begin
|
||||
try
|
||||
FTestTypes := LoadTestTypes;
|
||||
FTestOptions := LoadTestOptions;
|
||||
FSelectDirectoryFilename := LoadSelectDirectoryFilename;
|
||||
FExternalEditorName := LoadExternalEditorName;
|
||||
FLangFilterLanguageAbbr := LoadLangFilterLanguageAbbr;
|
||||
@ -634,7 +583,6 @@ begin
|
||||
|
||||
|
||||
SaveTestTypes;
|
||||
SaveTestOptions;
|
||||
SaveExternalEditorName;
|
||||
SaveSelectDirectoryFilename;
|
||||
SaveLangFilterLanguageAbbr;
|
||||
|
@ -21,9 +21,6 @@ Type
|
||||
pttCheckMismatchedOriginals);
|
||||
TPoTestTypes = Set of TPoTestType;
|
||||
|
||||
TPoTestOption = (ptoFindAllChildren);
|
||||
TPoTestOptions = set of TPoTestOption;
|
||||
|
||||
const
|
||||
optRunAllTests: TPoTestTypes = [];
|
||||
|
||||
@ -44,6 +41,7 @@ Type
|
||||
|
||||
TPoFamily = class
|
||||
private
|
||||
FLangID: TLangID;
|
||||
FMaster: TPOFile;
|
||||
FChild: TPOFile;
|
||||
FMasterName: String;
|
||||
@ -51,7 +49,6 @@ Type
|
||||
FOnTestStart: TTestStartEvent;
|
||||
FOnTestEnd: TTestEndEvent;
|
||||
FPoFamilyStats: TPoFamilyStats;
|
||||
FTestOptions: TPoTestOptions;
|
||||
FTestTypes: TPoTestTypes;
|
||||
procedure SetChildName(AValue: String);
|
||||
procedure SetMasterName(AValue: String);
|
||||
@ -61,7 +58,7 @@ Type
|
||||
procedure DoTestStart(const ATestName, APoFileName: String);
|
||||
procedure DoTestEnd(const ATestName: String; const ErrorCount: Integer);
|
||||
public
|
||||
constructor Create(const AMasterName, AChildName: String);
|
||||
constructor Create(const AMasterName, AChildName: String; ALangID: TLangID);
|
||||
destructor Destroy; override;
|
||||
|
||||
protected
|
||||
@ -81,7 +78,6 @@ Type
|
||||
property MasterName: String read FMasterName write SetMasterName;
|
||||
property ChildName: String read FChildName write SetChildName;
|
||||
property TestTypes: TPoTestTypes read FTestTypes write FTestTypes;
|
||||
property TestOptions: TPoTestOptions read FTestOptions write FTestOptions;
|
||||
property PoFamilyStats: TPoFamilyStats read FPoFamilyStats;
|
||||
property ShortMasterName: String read GetShortMasterName;
|
||||
property ShortChildName: String read GetShortChildName;
|
||||
@ -353,7 +349,7 @@ begin
|
||||
FChildName := AValue;
|
||||
end;
|
||||
|
||||
constructor TPoFamily.Create(const AMasterName, AChildName: String);
|
||||
constructor TPoFamily.Create(const AMasterName, AChildName: String; ALangID: TLangID);
|
||||
begin
|
||||
if (AMasterName <> '') then
|
||||
begin
|
||||
@ -367,6 +363,7 @@ begin
|
||||
FChildName := AChildName;
|
||||
//debugln('TPoFamily.Create: created ',FChildName);
|
||||
end;
|
||||
FLangID := ALangID;
|
||||
FPoFamilyStats := TPoFamilyStats.Create;
|
||||
end;
|
||||
|
||||
@ -693,7 +690,7 @@ begin
|
||||
end
|
||||
end;
|
||||
|
||||
if (ptoFindAllChildren in FTestOptions) then
|
||||
if FLangID = lang_all then
|
||||
begin
|
||||
SL := FindAllTranslatedPoFiles(FMasterName);
|
||||
//We want current Child (if currently assigned) at index 0
|
||||
|
@ -20,7 +20,6 @@ type
|
||||
FOnTestEnd: TTestEndEvent;
|
||||
FOnTestStart: TTestStartEvent;
|
||||
FPoFamilyStats: TPoFamilyStats;
|
||||
FTestOptions: TPoTestOptions;
|
||||
FTestTypes: TPoTestTypes;
|
||||
function GetItem(Index: Integer): TPoFamily;
|
||||
//procedure SetItem(Index: Integer; AValue: TPoFamily);
|
||||
@ -36,10 +35,10 @@ type
|
||||
procedure Add(PoFamily: TPofamily);
|
||||
function Count: Integer;
|
||||
procedure RunTests(out TotalTranslatedCount, TotalUntranslatedCount, TotalFuzzyCount: Integer; out TotalPercTranslated: Double);
|
||||
property LangID: TLangID read FLangID;
|
||||
property Items[Index: Integer]: TPoFamily read GetItem; // write SetItem;
|
||||
property PoFamilyStats: TPoFamilyStats read FPoFamilyStats;
|
||||
property TestTypes: TPoTestTypes read FTestTypes write FTestTypes;
|
||||
property TestOptions: TPoTestOptions read FTestOptions write FTestOptions;
|
||||
property OnTestStart: TTestStartEvent read FOnTestStart write FOnTestStart;
|
||||
property OnTestEnd: TTestEndEvent read FOnTestEnd write FOnTestEnd;
|
||||
end;
|
||||
@ -90,7 +89,7 @@ begin
|
||||
// ''',',ExtractFileName(ChildName),''')');
|
||||
if (ALangID = lang_all) or FileExistsUtf8(ChildName) then
|
||||
begin
|
||||
APoFamily := TPoFamily.Create(MasterName, ChildName);
|
||||
APoFamily := TPoFamily.Create(MasterName, ChildName, ALangID);
|
||||
Add(APoFamily);
|
||||
end
|
||||
else
|
||||
@ -136,10 +135,6 @@ var
|
||||
ThisTranslatedCount, ThisUntranslatedCount, ThisFuzzyCount: Integer;
|
||||
PoFamily: TPoFamily;
|
||||
begin
|
||||
if (FLangID = lang_all) then
|
||||
Include(FTestOptions,ptoFindAllChildren)
|
||||
else
|
||||
Exclude(FTestOptions,ptoFindAllChildren);
|
||||
ErrorCount := NoError;
|
||||
NonFuzzyErrorCount := NoError;
|
||||
WarningCount := NoError;
|
||||
@ -153,7 +148,6 @@ begin
|
||||
PoFamily.OnTestStart := FOnTestStart;
|
||||
PoFamily.OnTestEnd := FOnTestEnd;
|
||||
PoFamily.TestTypes := FTesttypes;
|
||||
PoFamily.TestOptions := FTestOptions;
|
||||
PoFamily.RunTests(ThisErrorCount, ThisNonFuzzyErrorCount, ThisWarningCount, ThisTranslatedCount, ThisUntranslatedCount, ThisFuzzyCount, InfoLog, StatLog, DupLog);
|
||||
PoFamily.PoFamilyStats.AddItemsTo(FPoFamilyStats);
|
||||
ErrorCount := ErrorCount + ThisErrorCount;
|
||||
@ -171,7 +165,7 @@ begin
|
||||
else
|
||||
InfoLog.Add(Format(sTotalErrors, [ErrorCount]));
|
||||
|
||||
if not (ptoFindAllChildren in TestOptions) then
|
||||
if FLangID <> lang_all then
|
||||
begin
|
||||
InfoLog.Add(Format(sTotalUntranslatedStrings, [IntToStr(TotalUntranslatedCount)]));
|
||||
InfoLog.Add(Format(sTotalFuzzyStrings, [IntToStr(TotalFuzzyCount)]));
|
||||
|
@ -55,7 +55,6 @@ type
|
||||
FTotalUntranslated: Integer;
|
||||
FTotalFuzzy: Integer;
|
||||
FTotalPercTranslated: Double;
|
||||
FTestOptions: TPoTestOptions;
|
||||
property Log: TStringList read FLog write FLog;
|
||||
property StatLog: TStringList read FStatLog write FStatLog;
|
||||
property DupLog: TStringList read FDupLog write FDupLog;
|
||||
@ -152,7 +151,7 @@ begin
|
||||
GraphStatForm.PoFamilyStats := Self.PoFamilyStats;
|
||||
GraphStatForm.Settings := Self.Settings;
|
||||
|
||||
if not (ptoFindAllChildren in FTestOptions) then
|
||||
if Self.PoFamilyList.LangID <> lang_all then
|
||||
begin
|
||||
GraphStatForm.TranslatedLabel.Caption := Format(sTranslatedStringsTotal, [
|
||||
IntToStr(FTotalTranslated), FTotalPercTranslated]);
|
||||
|
Loading…
Reference in New Issue
Block a user