⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ucomparison.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 3 页
字号:
{  JADD - Just Another DelphiDoc: Documentation from Delphi Source Code

Copyright (C) 2003-2008   Gerold Veith

This file is part of JADD - Just Another DelphiDoc.

DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.

DelphiDoc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
}


unit UComparison;

{Contains a dialog, ~[link TFormComparison], to compare two sets of parsed
 data. }

interface


uses
  Windows, Classes,
{$IFNDEF LINUX}
  ComCtrls, Controls, Forms, StdCtrls, ExtCtrls, CheckLst,
{$ELSE}
  Qt,
  QExtCtrls, QStdCtrls, QComCtrls, QControls, QForms, QCheckLst,
{$ENDIF}
  UBaseIdents;

type
  {A dialog to compare two sets of parsed data and to show all files,
   identifiers and their members and the differences between them. }
  TFormComparison = class(TForm)
    PanelAllData: TPanel;
    PanelFiles: TPanel;
    ListBoxFiles1: TListBox;
    ListBoxFiles2: TListBox;
    CheckBoxAutoFiles: TCheckBox;
    CheckBoxFilterFiles: TCheckBox;
    PanelSplitterFiles: TPanel;
    PanelIdentifiersAndMembers: TPanel;
    PanelIdentifiers: TPanel;
    ListBoxIdentifiers1: TListBox;
    ListBoxIdentifiers2: TListBox;
    CheckBoxAutoIdentifiers: TCheckBox;
    CheckBoxFilterIdentifiers: TCheckBox;
    PanelSplitterIdentifiers: TPanel;
    PanelMembers: TPanel;
    ListBoxMembers1: TListBox;
    ListBoxMembers2: TListBox;
    CheckBoxAutoMembers: TCheckBox;
    CheckBoxFilterMembers: TCheckBox;
    PanelSplitterMessages: TPanel;
    ListBoxMessages: TListBox;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure PanelSplitterMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure FormResize(Sender: TObject);
    procedure PanelSplitterMessagesMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure PanelAllDataResize(Sender: TObject);
    procedure PanelSplitterFilesMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure PanelIdentifiersAndMembersResize(Sender: TObject);
    procedure PanelSplitterIdentifiersMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    procedure PanelFilesResize(Sender: TObject);
    procedure PanelIdentifiersResize(Sender: TObject);
    procedure PanelMembersResize(Sender: TObject);
    procedure ListBoxFilesClick(Sender: TObject);
    procedure ListBoxIdentifiersClick(Sender: TObject);
    procedure ListBoxMembersClick(Sender: TObject);
    procedure CheckBoxFilterFilesClick(Sender: TObject);
    procedure CheckBoxFilterIdentifiersClick(Sender: TObject);
    procedure CheckBoxFilterMembersClick(Sender: TObject);
  private
    //first data of parsed files to compare
    FFirstData: TFileList;
    //second data of parsed files to compare
    FSecondData: TFileList;

    //Shows the list of parsed files.
    procedure ShowFiles(Data: TFileList; List: TListBox; Other: TFileList);
    //Shows the list of identifiers.
    procedure ShowIdents(Idents: TIdentifierList; List: TListBox;
                         Filter: Boolean; FilterIdents: TIdentifierList);

    { private declarations }
  public
    //Creates the dialog to compare the two sets of parsed data.
    constructor Create(First, Second: TFileList); reintroduce;

    { public declarations }
  end;



//Shows the dialog to compare the two sets of parsed data.
procedure MakeComparision(First, Second: TFileList);

implementation

{$R *.dfm}

uses SysUtils, Math, IniFiles,
     USettingsKeeper;



{Shows the dialog to compare the two sets of parsed data.
~param First, Second the sets of the parsed files to compare }
procedure MakeComparision(First, Second: TFileList);
begin
 with TFormComparison.Create(First, Second) do //create the dialog
  try
    ShowModal;                                 //show the dialog
  finally
   Free;                                       //free the dialog
  end;
end;













type

  {Loads and saves the settings of the form to compare Delphi projects. }
  TComparisonFormSettings = class(TFormSettings)
  private
    //whether when a file is selected the appropriate file of the other project
    //is also selected
    FAutoSelectFile: Boolean;
    //whether only files should be shown that don't have a matching file in the
    //other project
    FFilterFiles: Boolean;
    //whether when an identifier is selected the appropriate identifier of the
    //other project is also selected
    FAutoSelectIdentifier: Boolean;
    //whether only identifiers should be shown that don't have a matching
    //identifier in the other project
    FFilterIdentifiers: Boolean;
    //whether when a member is selected the appropriate member of the other
    //project is also selected
    FAutoSelectMember: Boolean;
    //whether only members should be shown that don't have a matching member in
    //the other project
    FFilterMembers: Boolean;

    //the height of the list of differences between selected
    //files/identifiers/members
    FMessageHeight: Integer;
    //the height of the lists of identifiers and members
    FIdentifierMemberHeight: Integer;
    //the height of the lists of members
    FMemberHeight: Integer;

  protected
  public
    //Loads the settings from the ini file.
    procedure LoadFromIni(Ini: TCustomIniFile); override;
    //Saves the settings to the ini file.
    procedure SaveToIni(Ini: TCustomIniFile); override;

    //Gets the settings from the form.
    procedure ReadValues(Form: TFormComparison);

    property AutoSelectFile: Boolean read FAutoSelectFile;
    property FilterFiles: Boolean read FFilterFiles;
    property AutoSelectIdentifier: Boolean read FAutoSelectIdentifier;
    property FilterIdentifiers: Boolean read FFilterIdentifiers;
    property AutoSelectMember: Boolean read FAutoSelectMember;
    property FilterMembers: Boolean read FFilterMembers;
    property MessageHeight: Integer read FMessageHeight;
    property IdentifierMemberHeight: Integer read FIdentifierMemberHeight;
    property MemberHeight: Integer read FMemberHeight;
  end;






{Loads the settings from the ini file.
~param Ini the ini file to load the settings from }
procedure TComparisonFormSettings.LoadFromIni(Ini: TCustomIniFile);
begin
 inherited LoadFromIni(Ini);             //read general form settings

 //read state of the check boxes
 FAutoSelectFile := Ini.ReadBool(Name, 'AutoSelectFile', FAutoSelectFile);
 FFilterFiles := Ini.ReadBool(Name, 'FilterFiles', FFilterFiles);
 FAutoSelectIdentifier := Ini.ReadBool(Name, 'AutoSelectIdentifier',
                                       FAutoSelectIdentifier);
 FFilterIdentifiers := Ini.ReadBool(Name, 'FilterIdentifiers',
                                    FFilterIdentifiers);
 FAutoSelectMember := Ini.ReadBool(Name, 'AutoSelectMember',
                                   FAutoSelectMember);
 FFilterMembers := Ini.ReadBool(Name, 'FilterMembers', FFilterMembers);

 //read heights of the lists
 FMessageHeight := Ini.ReadInteger(Name, 'MessageHeight', FMessageHeight);
 FIdentifierMemberHeight := Ini.ReadInteger(Name, 'IdentifierMemberHeight',
                                            FIdentifierMemberHeight);
 FMemberHeight := Ini.ReadInteger(Name, 'MemberHeight', FMemberHeight);
end;

{Saves the settings to the ini file.
~param Ini the ini file to save the settings to }
procedure TComparisonFormSettings.SaveToIni(Ini: TCustomIniFile);
begin
 inherited SaveToIni(Ini);           //write general form settings

 //write state of the check boxes
 Ini.WriteBool(Name, 'AutoSelectFile', FAutoSelectFile);
 Ini.WriteBool(Name, 'FilterFiles', FFilterFiles);
 Ini.WriteBool(Name, 'AutoSelectIdentifier', FAutoSelectIdentifier);
 Ini.WriteBool(Name, 'FilterIdentifiers', FFilterIdentifiers);
 Ini.WriteBool(Name, 'AutoSelectMember', FAutoSelectMember);
 Ini.WriteBool(Name, 'FilterMembers', FFilterMembers);

 //write heights of the lists
 Ini.WriteInteger(Name, 'MessageHeight', FMessageHeight);
 Ini.WriteInteger(Name, 'IdentifierMemberHeight', FIdentifierMemberHeight);
 Ini.WriteInteger(Name, 'MemberHeight', FMemberHeight);
end;


{Gets the settings from the form.
~param Form the form to read the values from }
procedure TComparisonFormSettings.ReadValues(Form: TFormComparison);
begin
 GetValuesFromForm(Form);               //get general values of the form

 //get state of the check boxes
 FAutoSelectFile := Form.CheckBoxAutoFiles.Checked;
 FFilterFiles := Form.CheckBoxFilterFiles.Checked;
 FAutoSelectIdentifier := Form.CheckBoxAutoIdentifiers.Checked;
 FFilterIdentifiers := Form.CheckBoxFilterIdentifiers.Checked;
 FAutoSelectMember := Form.CheckBoxAutoMembers.Checked;
 FFilterMembers := Form.CheckBoxFilterMembers.Checked;

 //get heights of the lists
 FMessageHeight := Form.ListBoxMessages.Height;
 FIdentifierMemberHeight := Form.PanelIdentifiersAndMembers.Height;
 FMemberHeight := Form.PanelMembers.Height;
end;




















{Creates the dialog to compare the two sets of parsed data.
~param First, Second the set of parsed data to compare }
constructor TFormComparison.Create(First, Second: TFileList);
var         Settings       :TComparisonFormSettings;   //to read ini settings
begin
 inherited Create(nil);                                //create the form

 FFirstData := First;                                  //save the parsed datas
 FSecondData := Second;

 ShowFiles(FFirstData, ListBoxFiles1, FSecondData);    //and show their files
 ShowFiles(FSecondData, ListBoxFiles2, FFirstData);

 //get object to load the settings from
 Settings := TComparisonFormSettings(TComparisonFormSettings.
                                                       GetSettings(ClassName));
 if not assigned(Settings) then        //no object initialized?
  begin                                  //create a new object
   Settings := TComparisonFormSettings.Create(ClassName);
   Settings.ReadValues(Self);            //initialize with the default values
   Settings.Initialize;                  //and read from the ini file
  end;
 Settings.SetValuesToForm(Self);       //initialize form with read values
 CheckBoxAutoFiles.Checked := Settings.AutoSelectFile;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -