Opkman: Preserve compatibility with older version(TPackageType/TLazPackageType).

git-svn-id: trunk@56503 -
This commit is contained in:
balazs 2017-11-27 08:22:33 +00:00
parent e7e4c0547f
commit a7bbd145e9
2 changed files with 24 additions and 2 deletions

View File

@ -82,6 +82,7 @@ type
FVSTPackages: TVirtualStringTree;
FVSTDetails: TVirtualStringTree;
FRepository: TRepository;
FSortDirection: TSortDirection;
FSerializablePackages: TSerializablePackages;
procedure EnableDisableButtons(const AEnable: Boolean);
procedure ShowHideControls(const AType: Integer);
@ -172,6 +173,7 @@ begin
bCancel.Caption := rsCreateRepositoryFrm_bCancel_Caption;
bCancel.Hint := rsCreateRepositoryFrm_bCancel_Hint;
miRepDetails.Caption := rsCreateRepositoryFrm_miRepDetails_Caption;
FSortDirection := sdAscending;
EnableDisableButtons(True);
ShowHideControls(0);
@ -398,7 +400,7 @@ begin
if FSerializablePackages.AddPackageFromJSON(JSON) then
begin
JSON := '';
SerializablePackages.Sort(stName, soAscendent);
FSerializablePackages.Sort(stName, soAscendent);
if FSerializablePackages.PackagesToJSON(JSON) then
begin
if SaveJSONToFile(ExtractFilePath(FRepository.FPath) + cRemoteJSONFile, JSON) then
@ -440,7 +442,7 @@ begin
if FSerializablePackages.AddPackageFromJSON(JSON) then
begin
JSON := '';
SerializablePackages.Sort(stName, soAscendent);
FSerializablePackages.Sort(stName, soAscendent);
if FSerializablePackages.PackagesToJSON(JSON) then
begin
if SaveJSONToFile(ExtractFilePath(FRepository.FPath) + cRemoteJSONFile, JSON) then
@ -472,6 +474,7 @@ begin
AddNewPackage
else
AddExistingPackage(AddRepositoryPackageFrm.JSONFile, AddRepositoryPackageFrm.PackageFile);
FVSTPackages.SortTree(0, FSortDirection);
end;
finally
AddRepositoryPackageFrm.Free;
@ -822,6 +825,7 @@ begin
SortDirection := opkman_VirtualTrees.sdAscending;
end;
SortTree(SortColumn, SortDirection, False);
FSortDirection := SortDirection;
end;
end;
end;

View File

@ -876,6 +876,15 @@ begin
LazarusPkg.FPCCompatibility := LazarusPkgsObj.Get('FPCCompatibility');
LazarusPkg.SupportedWidgetSet := LazarusPkgsObj.Get('SupportedWidgetSet');
LazarusPkg.PackageType := TLazPackageType(LazarusPkgsObj.Get('PackageType'));
{the package type wasn't changed in the packagelist.json to preserve compatibility with older versions, we need to convert from old to new
Old --> TPackageType = (ptRunAndDesignTime, ptDesignTime, ptRunTime, ptRunTimeOnly);
New --> TLazPackageType = (lptRunTime, lptDesignTime, lptRunAndDesignTime, lptRunTimeOnly);}
case Ord(LazarusPkg.PackageType) of
0: LazarusPkg.PackageType := lptRunAndDesignTime;
1: LazarusPkg.PackageType := lptDesignTime;
2: LazarusPkg.PackageType := lptRunTime;
3: LazarusPkg.PackageType := lptRunTimeOnly;
end;
LazarusPkg.DependenciesAsString := LazarusPkgsObj.Get('DependenciesAsString');
end;
end;
@ -970,6 +979,15 @@ begin
LazarusPkgObj.Add('LazCompatibility', LazarusPkg.LazCompatibility);
LazarusPkgObj.Add('FPCCompatibility', LazarusPkg.FPCCompatibility);
LazarusPkgObj.Add('SupportedWidgetSet', LazarusPkg.SupportedWidgetSet);
{the package type wasn't changed in the packagelist.json to preserve compatibility with older versions, we need to convert from new to old
New --> TLazPackageType = (lptRunTime, lptDesignTime, lptRunAndDesignTime, lptRunTimeOnly);
Old --> TPackageType = (ptRunAndDesignTime, ptDesignTime, ptRunTime, ptRunTimeOnly);}
case Ord(LazarusPkg.PackageType) of
0: LazarusPkg.PackageType := lptRunAndDesignTime;
1: LazarusPkg.PackageType := lptDesignTime;
2: LazarusPkg.PackageType := lptRunTime;
3: LazarusPkg.PackageType := lptRunTimeOnly;
end;
LazarusPkgObj.Add('PackageType', Ord(LazarusPkg.PackageType));
LazarusPkgObj.Add('DependenciesAsString', LazarusPkg.DependenciesAsString);
ALazarusPkgsArr.Add(LazarusPkgObj);